df.head() 时展示所有列
# 设置显示10列
pd.set_option('display.max_columns', 10)
# 设置显示全部列
pd.set_option('display.max_columns', None)
读取excel
方法1
# 读取excel表
xl = pd.ExcelFile(r'./excl_path/详情页列表.xlsx')
# 获取对应表单转换成 dataframe 格式
df = xl.parse("Sheet1", header=None)
方法2
pd.read_excel(r'./excl_path/详情页列表.xlsx', sheet_name='Sheet1') # sheet_name 设置读取哪个 excel 表单
读取csv
pd.pd.read_csv(csv_path, sep='\t') # sep 设置 csv 所用的分隔符,默认以逗号作为分隔符
读取数据时将所有数据类型全部设置为字符串
df = pd.read_csv(csv_path, dtype=str) # dtype 还可以为其他类型,例如 int,float 等等