Python-pandas Data analysis

Source: Internet
Author: User

pandas:powerful Python Data Analysis Toolkit Official document: http://pandas.pydata.org/pandas-docs/stable/

1. Import Package Pandas
Import Pandas as PD

  

2. Get the file name under the folder
Import osfilenames=[]
Path= "C:/users/forrest/pycharmprojects/test" for file in Os.listdir (path): filenames.append (file)

  

3. Read the first few lines of files (. csv file)
#-*-coding:utf-8-*-# #读前几行文件f = open ("C:/users/forrest/pycharmprojects/test/train.csv") for I in range (5):    Print ( F.readline (). Strip ())

  

4. Read and write files (. csv files)
File = Pd.read_csv ("./non-empty record/" +filenames[i],sep= '---> ', header=none) file.to_csv ("./Non-empty All/alldata.csv", header= False,mode= ' A ', index=false) #a追加

  

5. Pickle read-In and write
Import Cpickle as Pickleoutput = File ('./temp.pkl ', ' WB ') pickle.dump (t, output, True) output.close () F2 = file (' Temp.pkl ', ' RB ') a2 = Pickle.load (F2) f2.close ()

  

Python-pandas Data analysis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.