You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently writing a script to take data from an API and save it to an Excel file for non-technical users who need to access the data. One of the requirements is to have separate date and time column, rather than a single datetime column.
I am using pandas 0.17.0.
importpandasaspd# creating datetime seriesdates=pd.date_range('2015-01-01 00:00', '2015-01-01 03:00', freq='H')
dates=pd.Series(dates)
# setting one record to NaTdates.iloc[0] =pd.NaT# converting to date dates.apply(lambdax: x.date()) # ignores the NaT# converting to timedates.apply(lambdax: x.time()) # fails with error "NaTType does not support time"
I expected NaTType to behave in the same way for converting into a time as it did for a date i.e. returning NaT.
The full error is:
---------------------------------------------------------------------------ValueErrorTraceback (mostrecentcalllast)
<ipython-input-98-b34fccfc4c06>in<module>()
9dates.apply(lambdax: x.date()) # ignores the NaT10# converting to time--->11dates.apply(lambdax: x.time()) # fails with error "NaTType does not support time"C:\Users\Nathan\Anaconda\lib\site-packages\pandas\core\series.pycinapply(self, func, convert_dtype, args, **kwds)
2158values=lib.map_infer(values, lib.Timestamp)
2159->2160mapped=lib.map_infer(values, f, convert=convert_dtype)
2161iflen(mapped) andisinstance(mapped[0], Series):
2162frompandas.core.frameimportDataFramepandas\src\inference.pyxinpandas.lib.map_infer (pandas\lib.c:62187)()
The text was updated successfully, but these errors were encountered:
I am currently writing a script to take data from an API and save it to an Excel file for non-technical users who need to access the data. One of the requirements is to have separate date and time column, rather than a single datetime column.
I am using pandas 0.17.0.
I expected NaTType to behave in the same way for converting into a time as it did for a date i.e. returning NaT.
The full error is:
The text was updated successfully, but these errors were encountered: