We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In [1]: import pandas as pd; pd.__version__ Out[1]: '0.26.0.dev0+857.g2ade669c7' In [2]: dti = pd.DatetimeIndex(["2019-01-01", pd.NaT]) In [3]: dti.strftime("%Y-%m-%d") Out[3]: Index(['2019-01-01', 'NaT'], dtype='object')
This behavior carries over to Series.dt.strftime as well:
Series.dt.strftime
In [4]: s = pd.Series(dti) In [5]: s.dt.strftime("%Y-%m-%d").values Out[5]: array(['2019-01-01', 'NaT'], dtype=object)
DatetimeIndex.strftime and Series.dt.strftime do not maintain missing values and instead coerce them to strings.
DatetimeIndex.strftime
I'd expect NaT to get converted to np.nan.
NaT
np.nan
pd.show_versions()
commit : 2ade669 python : 3.7.3.final.0 python-bits : 64 OS : Darwin OS-release : 18.6.0 machine : x86_64 processor : i386 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8
pandas : 0.26.0.dev0+857.g2ade669c7 numpy : 1.16.4 pytz : 2019.1 dateutil : 2.8.0 pip : 19.1.1 setuptools : 41.0.1 Cython : 0.29.13 pytest : 4.6.2 hypothesis : 4.23.6 sphinx : 1.8.5 blosc : None feather : None xlsxwriter : 1.1.8 lxml.etree : 4.3.3 html5lib : 1.0.1 pymysql : None psycopg2 : None jinja2 : 2.10.1 IPython : 7.5.0 pandas_datareader: None bs4 : 4.7.1 bottleneck : 1.2.1 fastparquet : 0.3.0 gcsfs : None lxml.etree : 4.3.3 matplotlib : 3.1.0 numexpr : 2.6.9 odfpy : None openpyxl : 2.6.2 pandas_gbq : None pyarrow : 0.11.1 pytables : None s3fs : 0.2.1 scipy : 1.2.1 sqlalchemy : 1.3.4 tables : 3.5.2 xarray : 0.12.1 xlrd : 1.2.0 xlwt : 1.3.0 xlsxwriter : 1.1.8
The text was updated successfully, but these errors were encountered:
Fix NaT representation for newer version of Pandas (pandas-dev/pandas…
56b1889
…#29578 - it was a feature, not a bug! :))
Successfully merging a pull request may close this issue.
Code Sample, a copy-pastable example if possible
This behavior carries over to
Series.dt.strftime
as well:Problem description
DatetimeIndex.strftime
andSeries.dt.strftime
do not maintain missing values and instead coerce them to strings.Expected Output
I'd expect
NaT
to get converted tonp.nan
.Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 2ade669
python : 3.7.3.final.0
python-bits : 64
OS : Darwin
OS-release : 18.6.0
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 0.26.0.dev0+857.g2ade669c7
numpy : 1.16.4
pytz : 2019.1
dateutil : 2.8.0
pip : 19.1.1
setuptools : 41.0.1
Cython : 0.29.13
pytest : 4.6.2
hypothesis : 4.23.6
sphinx : 1.8.5
blosc : None
feather : None
xlsxwriter : 1.1.8
lxml.etree : 4.3.3
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10.1
IPython : 7.5.0
pandas_datareader: None
bs4 : 4.7.1
bottleneck : 1.2.1
fastparquet : 0.3.0
gcsfs : None
lxml.etree : 4.3.3
matplotlib : 3.1.0
numexpr : 2.6.9
odfpy : None
openpyxl : 2.6.2
pandas_gbq : None
pyarrow : 0.11.1
pytables : None
s3fs : 0.2.1
scipy : 1.2.1
sqlalchemy : 1.3.4
tables : 3.5.2
xarray : 0.12.1
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.1.8
The text was updated successfully, but these errors were encountered: