我正在尝试在jupyter中导入这个简短的xlsx
使用此代码
import pandas as pd
fields=['Date', 'A', 'C']
df = pd.read_excel('/home/maspis/Scrivania/date_try.xlsx', sheet_name='I1', usecols=fields)
#df['Date']= pd.to_datetime(df['Date'])
df.info()
我得到以下输出:
<class 'pandas.core.frame.DataFrame'>
Index: 0 entries
Empty DataFrame'
然后,当我使用pd.to_datetime时,得到以下内容
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
3077 try:
-> 3078 return self._engine.get_loc(key)
3079 except KeyError:
......
KeyError: 'Date'
您能帮我解决这个问题吗?
谢谢, G