pandas操作excel全总结

https://gairuo.com/p/pandas-read-excel
https://cloud.tencent.com/developer/article/1785768

1、pandas.read_excel() 
pandas.read_excel(filename, sheet_name=0, header=0, names=None, index_col=None, usecols=None, squeeze=False, dtype=None, engine=None, converters=None, true_values=None, false_values=None, skiprows=None, nrows=None, na_values=None, keep_default_na=True, verbose=False, parse_dates=False, date_parser=None, thousands=None, comment=None, skipfooter=0, convert_float=True, mangle_dupe_cols=True, **kwds)
filename: 相对路径,绝对路径,url
sheet_name:可以为数字或名字,默认为第0个sheet
header:数据的表头,默认为第一行(header=0)。无表头(header=None
names:=[‘a’,’b’,’c’]可以自己设置列标题(如果表头不为None,替代表头)
index_col=None:默认加一列(从0开始),否则以指定的列为index

注意:
pandas中pd_wb.columns 不加是个index; .tolist得到的是list;.values得到的是ndarray(功能更强,可计算,中间没有逗号分隔)
pd_wb[“inchikey”]不加是个series; .tolist得到的是list;.values得到的是ndarray

When engine=None, the following logic will be used to determine the engine:

  • If path_or_buffer is an OpenDocument format (.odf, .ods, .odt), then odf will be used.
  • Otherwise if path_or_buffer is an xls format, xlrd will be used.
  • Otherwise if path_or_buffer is in xlsb format, pyxlsb will be used.
  • Otherwise openpyxl will be used.




发表评论

您的邮箱地址不会被公开。 必填项已用 * 标注