0

I still do not quite understand the SettingWithCopyError, none of the following seem to work:

df['year'] = df['date'].dt.year

df.loc[:,'year'] = df['date'].dt.year

df.loc[:,'year'] = df.loc[:,'date'].dt.year

pd.__version__ '0.25.3'

Thank you!

The complete code:

df = other_df[['id','date','price']]

def date_augment(df, col):
    field =  df[col]
    attr = ['Year', 'Month', 'Week', 'Day', 'Dayofweek', 'Dayofyear', 'Is_month_end', 'Is_month_start', 
        'Is_quarter_end', 'Is_quarter_start', 'Is_year_end', 'Is_year_start']
    for n in attr: df[n] = getattr(field.dt, n.lower())
    df['Elapsed'] = field.astype(np.int64) // 10 ** 9

date_augment(df, 'date')
Dmitriy Grankin
  • 568
  • 9
  • 21

0 Answers0