pyreadstat
pyreadstat copied to clipboard
enforce DATETIME type on empty datetime column
I observed that "dates_as_pandas_datetime=True" in readstat_sas7bdat does not enforce DATETIME type if a datetime column has only NaN values.
thanks for the report. As requested in the issue template, please provide a piece of code and a file to reproduce the issue.
>>> 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
solved in version 1.2.0