0

The df has a column named isInDST which is a bool object type.

df.isInDST

0          True
1          True
2          True
3          True
4          True
5          True
6          True
7          True
8          True
9          True
...         ...  
849350    False
849351    False
849352    False
849353    False
849354    False
849355    False
849356    False
849357    False
849358    False
849359    False
Name: isInDST, Length: 849360, dtype: object

This isInDST column was created from a map function:

df['isInDST'] = pd.DatetimeIndex(df['time']).tz_localize('UTC').tz_convert('Australia/Victoria').map(lambda x : bool(x.dst().total_seconds()!=0))

I think my question is how to edit the map function to make isInDST become a bool primitive type rather than object?

aneroid
  • 12,287
  • 3
  • 38
  • 59
alextc
  • 2,829
  • 8
  • 52
  • 97

1 Answers1

0

Just fix your problem

df['isInDST'] = df['isInDST'].astype('bool')

Update

df['isInDST'] = pd.DatetimeIndex(df['time']).tz_localize('UTC').tz_convert('Australia/Victoria').map(lambda x : x.dst().total_seconds()!=0)
BENY
  • 296,997
  • 19
  • 147
  • 204