pandas中pd.read_excel

Help on function read_excel in module pandas.io.excel:

read_excel(io, sheet_name=0, header=0, skiprows=None, skip_footer=0, index_col=None, names=None, usecols=None, parse_dates=False, date_parser=None, na_values=None, thousands=None, convert_float=True, converters=None, dtype=None, true_values=None, false_values=None, engine=None, squeeze=False, **kwds)
    Read an Excel table into a pandas DataFrame
read_excel与to_excel方便的与excel交互

header 表⽰数据中是否存在列名,如果在第0行就写就写0,并且开始读数据时跳过相应的行数,不存在可以写none

names 表示要用给定的列名来作为最终的列名

encoding 表⽰数据集的字符编码,通常而言一份数据为了⽅便的进⾏⽂件传输都以utf-8作为标准
这里介绍一些常用的参数:

读取处理:
skiprows:跳过⼀定的⾏数
nrows:仅读取⼀定的⾏数
skipfooter:尾部有固定的⾏数永不读取
skip_blank_lines:空⾏跳过

内容处理:
sep/delimiter:分隔符很重要,常用有逗号,空格和Tab('\t')
na_values:指定应该被当作na_values的数值
thousands:处理数值类型时,每千位分隔符并不统⼀ (1.234.567,89或者1,234,567.89都可能),此时要把字符串转化为数字需要指明千位分隔符

收尾处理:
index_col:将真实的某列(列的数,甚⾄列名)当作indexs
queeze:仅读到⼀列时,不再保存为pandas.DataFrame⽽是pandas.Series

摘自https://blog.csdn.net/geekleee/article/details/52810084

猜你喜欢

转载自blog.csdn.net/weixin_41512727/article/details/80736862
今日推荐