pandas IO操作
阿新 • • 發佈:2018-03-18
html ssi mina sof -s wikipedia 真的 das stat
官方文檔:
Format Type | Data Description | Reader | Writer |
---|---|---|---|
text | CSV | read_csv | to_csv |
text | JSON | read_json | to_json |
text | HTML | read_html | to_html |
text | Local clipboard | read_clipboard | to_clipboard |
binary | MS Excel | read_excel | to_excel |
binary | HDF5 Format | read_hdf | to_hdf |
binary | Feather Format | read_feather | to_feather |
binary | Msgpack | read_msgpack | to_msgpack |
binary | Stata | read_stata | to_stata |
binary | SAS | read_sas | |
binary | Python Pickle Format | read_pickle | to_pickle |
SQL | SQL | read_sql | to_sql |
SQL | Google Big Query | read_gbq | to_gbq |
其中重點想說一說read_clipboard()和read_csv()這兩個典型的例子,前者從粘貼板讀取和寫入,在實際應用中真的是非常的方便,有點開始佩服那些開發者的腦洞了。
後者是最常用的。源碼如下:(read_csv和to_csv類似)
1 def to_csv(self, path_or_buf=None, sep=",", na_rep=‘‘, float_format=None, 2 columns=None, header=True, index=True, index_label=None, 3 mode=‘w‘, encoding=None, compression=None, quoting=None, 4 quotechar=‘"‘, line_terminator=‘\n‘, chunksize=None, 5 tupleize_cols=None, date_format=None, doublequote=True, 6 escapechar=None, decimal=‘.‘): 7 r"""Write DataFrame to a comma-separated values (csv) file
pandas IO操作