【发布时间】:2019-08-18 16:30:39
【问题描述】:
我正在尝试解决这个问题,我很确定代码是正确的,但它总是给我同样的错误。
我试过这个:
import datetime
from datetime import datetime as datet
test_df = shapefile.copy()
test_df['timestamp'] = prediction_time
test_df['allah1__27'] = shapefile.allah1__27.astype('int64')
test_df['hour'] = prediction_time.hour
test_df['weekday'] = prediction_time.weekday()
test_df['month'] = prediction_time.month
def add_join_key(df):
df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datetime.isoformat)
df = df.set_index('join_key')
return df
weath_df = wdf.loc[prediction_time]
test_df = add_join_key(test_df)
weath_df = add_join_key(weath_df.reset_index())
我得到了这个错误:
AttributeError: module 'datetime' has no attribute 'isoformat'
我也试过了:
def add_join_key(df):
df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datet.isoformat)
df = df.set_index('join_key')
return df
weath_df = wdf.loc[prediction_time]
test_df = add_join_key(test_df)
weath_df = add_join_key(weath_df.reset_index())
我得到了这个错误:
AttributeError: DataFrame' object has no attribute 'allah1__27'
我错过了什么吗?
【问题讨论】:
标签: python datetime machine-learning arcpy