这是我在这里的第一个问题,所以如果我没有遵守完美的礼仪,请原谅我。我已经找了6个小时的答案,所以我想是时候问了。我是Python的新手,我正在尝试使用Selenium自动化数据输入。我做得很好,但我仍然坚持从Excel中提取数据。数据拉取不是问题,但告诉我的excel删除最上面的一行,或者移到下一行。以下是我的脚本示例:
import pandas as pd
from pandas import ExcelWriter
import numpy as np
xl = pd.ExcelFile('C:\\Users\\Steph_000\\Desktop\\students2.xlsx')
xl
wr = pd.ExcelWriter('C:\\Users\\Steph_000\\Desktop\\students2.xlsx')
xl.sheet_names
['Sheet1']
df = xl.parse('Sheet1') #This reads the sheet into a dataframe
df
cp = pd.read_excel('C:\\Users\\Steph_000\\Desktop\\students2.xlsx')
IDNum = cp[:1] #This pulls the first row as a variable
print(IDNum) #This is where it prints to the search bar to look the student up
chart = cp[1:] #This pulls everything but the first row as a variable
print(chart)
df.to_excel(wr, 'Sheet1')
wr.save() #This is supposed to overwrite it, but just saves it as blank
不管我做什么,我都不能让它往上移动,或者诸如此类的事情。我真的很挣扎,也很沮丧。如果必要的话,我将使用与Pandas不同的Python包装器,但我已经尝试过openpyxl、xlrd和xlwr,但都没有用!把我的头发拔出来,先谢谢你!在
请看下面的示例:
看看这个:
http://xlsxwriter.readthedocs.io/working_with_pandas.html
相关问题 更多 >
编程相关推荐