from pandas import read_csv, read_excel
import os
# DataFrame
df = read_csv('scientists.csv', sep=",")
# DataFrame
df_path_1 = "./out/df_path_1.xls"
# 直接把这个数据,保存起来
if not os.path.exists(df_path_1):
df.to_excel(df_path_1)
# 把索引去调
df_path_2 = "./out/df_path_2.xls"
# 直接把这个数据,保存起来
if not os.path.exists(df_path_2):
df.to_excel(df_path_2, index=False)
# 一维的Series
age = df["Age"]
age.to_excel("./out/ss.xls", index=True)
# 修改表的名称
df_path_3 = "./out/df_path_3.xls"
if not os.path.exists(df_path_3):
df.to_excel(df_path_3, index=False, sheet_name="hello")
# 读取excel的数据
df = read_excel(df_path_3)
print(df)
print(type(df))
print(df["Age"])