1、首先创建一个文件内容可以自己定义。

2、在编辑器里面导入需要的包
import pandasas pd让后使用read_excel打开文件。注意:如果你的内容特别多的时候千万不要这要这样输出,电脑会被卡死的

3.shape输出你的文档有多少行和多少列
4.head()默认查看前5行,tail(1),看最后面1行
5.header, 用哪一行作列名如果表的前面有其他无关的内容时候可以使用header设置那一行作为列名。

第一行不是列名的时候可以使用header来操作:

如果第一行为空没有一列有数据会自动跳过。如果没有列名的时候可以将header设置为None

为了方便阅读我们可以通过columns来添加列名

同时我们可以采用to_excel(),输出保存


重新生成的文件前面多了一列索引,我们可以采用book=book.set_index('ID')来设置

6.index_col, 用作索引的列
7.采用names添加列名,吧ID作为索引列

8.usecols读取需要的列重0开始计算

9.converters ,强制规定列数据类型

10.skiprows,跳过前几行;skipfooter跳过末尾n行,nrows ,需要读取的行数

网友评论