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