import pandas as pd
# 构建数据
df = pd.DataFrame({'ID': [1, 2, 3], 'Name':['Luck', 'NIck', 'Vickor']})
# 设置ID为索引(默认再添加一列新的数据)
df = df.set_index('ID')
# 写入数据(to_excel方法(此处写至001.xlsx中))
df.to_excel('001.xlsx')
print("It's OK ")
创建好的文件如下所示:
友情链接:
import pandas as pd
# 构建数据
df = pd.DataFrame({'ID': [1, 2, 3], 'Name':['Luck', 'NIck', 'Vickor']})
# 设置ID为索引(默认再添加一列新的数据)
df = df.set_index('ID')
# 写入数据(to_excel方法(此处写至001.xlsx中))
df.to_excel('001.xlsx')
print("It's OK ")
创建好的文件如下所示:
友情链接: