python - 在 read.excel() 上弹出回溯消息并接收类型错误
问题描述
我的项目是使用python进行分析。我有一些关于 excel 的数据,但我只需要使用一些数据而不是所有数据(即特定日期,例如仅从 1 月到 2 月)。我的问题是
- 如何仅选择所需的数据(如特定日期)并插入到 python 代码中?
- 当我尝试运行文件 (PMEB_Para.py) 时出现此错误,我可以知道该错误是什么意思吗?这是我收到的错误
C:\Users\user\Desktop\CIV4210\Research\Package for FYP\data and code>python PMEB_Main.py
Traceback (most recent call last):
File "PMEB_Main.py", line 483, in <module>
Tb, Station, Rough, Veg, Sp = readdata(Para.period)
File "C:\Users\user\Desktop\CIV4210\Research\Package for FYP\data and code\PMEB_Para.py", line 397, in readdata
rough = pd.read_excel('roughness.xlsx', parse_dates=['Dt'], dtype=Dtype, dayfirst=True)
File "C:\Users\user\AppData\Roaming\Python\Python36\site-packages\pandas\util\_decorators.py", line 296, in wrapper
return func(*args, **kwargs)
TypeError: read_excel() got an unexpected keyword argument 'dayfirst'
PMEB_Para.py 文件中第 390-397 行的代码
def readdata(period):
station = readstation(period)
tb = pd.read_csv('TB.csv', dtype=Dtype, parse_dates=['Dt'], dayfirst=True)
tb = tb.loc[(tb['Dt'] > period[0]) & (tb['Dt'] < period[1])]
tb['Date'] = [x.date() for x in tb['Dt']]
tb['Time'] = [x.time() for x in tb['Dt']]
tb = tb.sort_values(['Date', 'Quad', 'BI', 'Pol'])
rough = pd.read_excel('roughness.xlsx', parse_dates=['Dt'], dtype=Dtype, dayfirst=True)
提前感谢您的时间!
解决方案
推荐阅读
- flutter - 如何在列表中保存共享偏好?
- python - 在多终端中打开 Python 函数
- c# - 异步代码似乎是并行运行的
- css - 在 CSS Grid 中从底部开始填充单元格
- python - Python在Windows上正确解码字节字符串但在linux上不起作用。给出Unicode错误
- android - Flutter 应用程序在 Android 模拟器上运行,但不在物理设备上(OnePlus 7T)
- android - 如何为移动应用设计循环事件系统?
- java - 如何从嵌套的 ArrayList 访问特定元素
- jenkins - Jenkins Pipeline sh 命令产生 java.io.NotSerializableException: java.util.regex.Matcher
- angular - 如何检查数组是否包含值