I am working with timedeltas and it seems this code
copy_for_U.Time.astype('timedelta64[m]',copy=False);
does not change the dataframe - as it should, if I understood correctly from the doc, where it says:
Signature: full_df.Time.astype(dtype, copy=True, raise_on_error=True, **kwargs) Docstring: Cast object to input numpy.dtype Return a copy when copy = True (be really careful with this!)
In order for the changes to be applied to the dataframe, one needs to assign the dataframe to the variable one wants (or pass inplace=True
- this may be a nice thread to read).
Also, when doing that, you don't need to pass the copy=False
, as @jezrael suggests.
Given that, this should solve your problem
copy_for_U.Time = copy_for_U.Time.astype('timedelta64[m]')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With