pandas I/O API 是一组访问的顶级读取器函数,如 pandas.read_csv(),通常返回一个 pandas 对象。相应的编写器函数是访问的对象方法,如 DataFrame.to_csv()
数据准备

读取文件


执行to_csv会将索引存入到文件当中,再次读取时发现变成了单独的一列数据


若要删除索引这一列,可以指定index参数为False,删除原来的文件,重新保存一次

H5文件是以层级数据格式(HDF)第5版保存的数据文件,它包含科学数据的多维数组,HDF5文件的读取和存储需要指定一个键,值为要存储的DataFrame
HDF5在存储的时候支持压缩,使用的方式是blosc,这个是速度最快的,也是pandas默认支持的,使用压缩可以提磁盘利用率,节省空间,HDF5还是跨平台的,可以轻松迁移到hadoop上面,应优先选择使用HDF5文件存储
columns:values的形式输出index:{columns:values}...的形式输出columns:{index:values}的形式输出下表包含可用的读取器和写入器
| 格式类型 | 数据描述 | 读取器 | 编写器 |
|---|---|---|---|
| text | CSV | read_csv | to_csv |
| text | Fixed-Width Text File | read_fwf | |
| text | JSON | read_json | to_json |
| text | HTML | read_html | to_html |
| text | LaTeX | Styler.to_latex | |
| text | XML | read_xml | to_xml |
| text | Local clipboard | read_clipboard | to_clipboard |
| binary | MS Excel | read_excel | to_excel |
| binary | OpenDocument | read_excel | |
| binary | HDF5 Format | read_hdf | to_hdf |
| binary | Feather Format | read_feather | to_feather |
| binary | Parquet Format | read_parquet | to_parquet |
| binary | ORC Format | read_orc | to_orc |
| binary | Stata | read_stata | to_stata |
| binary | SAS | read_sas | |
| binary | SPSS | read_spss | |
| binary | Python Pickle Format | read_pickle | to_pickle |
| SQL | SQL | read_sql | to_sql |
| SQL | Google BigQuery | read_gbq | to_gbq |
官网:https://pandas.pydata.org/pandas-docs/version/0.25/user_guide/io.html#io-read-csv-table
或:https://pandas.pydata.org/docs/user_guide/io.html
学习导航:http://xqnav.top/
上一篇:双子座伤感的句子