迎合大于2261的日期,即9999-12-31 00:00:00

时间:2018-05-31 10:15:16

标签: python pandas dataframe

我已将数据源从CSV切换为SQL查询。以前我会成功地将所有maturity_date转换为2261(如果它们比今年更大)(@jezrael):

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的需求?

0 个答案:

没有答案