I have a.netcdf dataset and I want to convert the time to pandas datetime format. The entries look like this:
<xarray.DataArray 'time' ()>
array(19810101.47916667)
Coordinates:
time float64 1.981e+07
Attributes:
axis: T
calendar: proleptic_gregorian
standard_name: time
units: day as %Y%m%d.%f
When I try to convert the data like this
pd.to_datetime(19810101.47916667,format='%Y%m%d.%f')
I get the error "time data '19810101' does not match format '%Y%m%d.%f' (match)". I fail to undertand what exactly is going wrong here. Especially since this is exactly the format mentioned in the.netcdf data (as you can see above). Can someone tell me what I am missing?
You simply need to make your date value a string as below:
pd.to_datetime("19810101.47916667",format='%Y%m%d.%f'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.