2. Panda common read

Time:2021-1-25

1、 Text reading and writing

name receive Representative (meaning) default
filepath string File path nothing
sep string Divider ‘,’
header Int/sequence List a row Infer auto search
names array, Listing None
Index_col int,sequence,False The location of the index column None
dtype Dict Write data type None
enigne c/python Data analysis engine c
nrows int Read the first n lines Nome

1. Reading

(1)read_table

Read TXT format

pd.read_ Table ('File address / file. TXT ')

(2)read_csv

Read CSV format

pd.read_ CSV ('File address / file. CSV ')

2. Write

to_csv

Can write to TXT, CSV format

pd.to_ CSV ('File address / file. CSV / TXT ')

2、 Excel reading and writing

parameter receive express default
Io string File path nothing
Sheetname String/ int Location of Excel internal data table 0
header Int /sequence A row of data is used as the column name, int is used as the column name, and sequence is used as multiple column index infer
names array Listing None
index_col Int/sequence/Flash The location of the index column, and the multiple column index when sequenc None
dtype dict Write data type (column name key, data format values) None

1. Excel reading

read_excel

Excel common format XLS, xlsx

pd.read_ Excel ('File address / file. XLS / xlsx ')

Examples

2. Excel reading

to_excel

Excel common format XLS, xlsx

pd.to_ Excel ('File address / file. XLS / xlsx ')

Examples