pyreadstat icon indicating copy to clipboard operation
pyreadstat copied to clipboard

enforce DATETIME type on empty datetime column

Open ankravch opened this issue 3 years ago • 2 comments

I observed that "dates_as_pandas_datetime=True" in readstat_sas7bdat does not enforce DATETIME type if a datetime column has only NaN values.

ankravch avatar Aug 22 '22 04:08 ankravch

thanks for the report. As requested in the issue template, please provide a piece of code and a file to reproduce the issue.

ofajardo avatar Aug 22 '22 08:08 ofajardo

>>> from pyreadstat import read_sas7bdat
>>> df,meta=read_sas7bdat('null_date.sas7bdat', dates_as_pandas_datetime=True)
>>> df
          V1   V2
0 2022-08-22  NaN
1        NaT  NaN
>>> df.dtypes
V1    datetime64[ns]
V2            object
dtype: object
>>> meta.original_variable_types
{'V1': 'DATE', 'V2': 'DATE'}

In the attached null_date.sas7bdat.zip .zip to be removed. null_date.sas7bdat.zip

ankravch avatar Aug 22 '22 14:08 ankravch

solved in version 1.2.0

ofajardo avatar Oct 25 '22 06:10 ofajardo