我已将数据源从CSV切换到SQL查询。以前我会通过(@jezrael)成功地将所有maturity_date
转换为2261,如果它们大于今年的值:
df_With_NaN = pd.read_sql(strSql, pyodbc.connect(connstr))
m = df_With_NaN['maturity_date'].str[:4].astype(float) > 2261
df_With_NaN['maturity_date'] = df_With_NaN['maturity_date'].mask(m, '2261' + df_With_NaN['maturity_date'].str[4:])
但现在我得到了这行的错误:
df_With_NaN['maturity_date'] = pd.to_datetime(df_With_NaN['maturity_date'])
OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 9999-12-31 00:00:00
数据类型:
maturity_date 460862 non-null object
SQL Server到Pandas是否需要额外的转换?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐