【pandas】使用笔记


记录贴。

import pandas as pd

文件

可结合参考:

.read_excel

  • pandas.read_excel — pandas 1.3.3 documentation (pydata.org)
  • Pandas read_excel()参数详解_leenuxcore的博客-CSDN博客_read_excel参数

Read an Excel file into a pandas DataFrame.
Supports xls, xlsx, xlsm, xlsb, odf, ods and odt file extensions read from a local filesystem or URL. Supports an option to read a single sheet or a list of sheets.

.ExcelWriter

  • pandas.ExcelWriter — pandas 1.3.3 documentation (pydata.org)

Class for writing DataFrame objects into excel sheets.
Default is to use xlwt for xls, openpyxl for xlsx, odf for ods. See DataFrame.to_excel for typical usage.
The writer should be used as a context manager. Otherwise, call close() to save and close any opened file handles.

.read_csv

  • pandas.read_csv — pandas 1.3.3 documentation (pydata.org)
  • 【python】pandas库pd.read_csv操作读取分隔符csv文件和文本text文件参数整理与实例_brucewong0516的博客-CSDN博客_pd.read_csv

Read a comma-separated values (csv) file into DataFrame.
Also supports optionally iterating or breaking of the file into chunks.

data_txt = pd.read_csv('test.txt', sep='\t', header=None)   # DataFrame
# data_txt.iloc[0]
data1_txt = pd.read_csv('test.txt', sep='\t', header=None).values  # array
# data1_txt[0]