Skip to content
New issue

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

BUG: In Series all null-values are printed as NaN #45263

Closed
3 tasks done
realead opened this issue Jan 8, 2022 · 7 comments · Fixed by #45283
Closed
3 tasks done

BUG: In Series all null-values are printed as NaN #45263

realead opened this issue Jan 8, 2022 · 7 comments · Fixed by #45283
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@realead
Copy link
Contributor

realead commented Jan 8, 2022

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the master branch of pandas.

Reproducible Example

import pandas as pd
import numpy as np
s=pd.Series([1, 2, 3, 4], [True, None, np.nan, pd.NaT])
print(s)

Issue Description

All null-keys are printed as NaN:

True    1
NaN     2
NaN     3
NaN     5

This is confusing

Expected Behavior

True    1
None    2
nan    3
NaT   5

would be clearer

Installed Versions

INSTALLED VERSIONS

commit : c950850
python : 3.8.5.final.0
python-bits : 64
OS : Linux
OS-release : 4.4.0-53-generic
Version : #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.4.0.dev0+1594.gc950850
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.3
setuptools : 58.0.4
Cython : 0.29.24
pytest : 6.0.2
hypothesis : 5.28.0
sphinx : 3.2.1
blosc : None
feather : None
xlsxwriter : 1.3.6
lxml.etree : 4.5.2
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: None
bs4 : 4.9.1
bottleneck : 1.3.2
fsspec : 0.8.2
fastparquet : 0.4.1
gcsfs : 0.7.1
matplotlib : 3.3.2
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.5
pandas_gbq : None
pyarrow : 1.0.1
pyxlsb : None
s3fs : 0.4.2
scipy : 1.5.2
sqlalchemy : 1.3.19
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.16.1
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.51.2
zstandard : None

@realead realead added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 8, 2022
@realead
Copy link
Contributor Author

realead commented Jan 8, 2022

This is the underlying issue in #45222 if we would like to fix it less superficial than in #45262.

@simonjayhawkins
Copy link
Member

indeed. and just as indicted in #45222 (comment) the underlying index attribute is correct

s = pd.Series([1, 2, 3, 4], [True, None, np.nan, pd.NaT])
s.index
Index([True, None, nan, NaT], dtype='object')

and this appears to have been the case since at least 0.25.3

@simonjayhawkins simonjayhawkins added Output-Formatting __repr__ of pandas objects, to_string and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 8, 2022
@simonjayhawkins simonjayhawkins added this to the Contributions Welcome milestone Jan 8, 2022
@jreback jreback modified the milestones: Contributions Welcome, 1.4 Jan 10, 2022
@realead
Copy link
Contributor Author

realead commented Jan 13, 2022

We have a similar issue with DataFrames as well:

import pandas as pd
import numpy as np
s=pd.DataFrame([1, 2, 3, 4], [True, None, np.nan, pd.NaT])
print(s)

leads to

      0
True  1
NaN   2
NaN   3
NaN   4

@realead
Copy link
Contributor Author

realead commented Jan 13, 2022

Another problematic example:

import pandas as pd
import numpy as np

d = {np.nan: [1, 2], None: [3, 4], pd.NaT: [6,7], True: [8,9]}
s=pd.DataFrame(data=d)

print(s.columns)
print(s)

leads to

Index([nan, None, NaT, True], dtype='object')
   NaN  NaN  NaN  True
0    1    3    6     8
1    2    4    7     9

here is the column index concerned

@jreback
Copy link
Contributor

jreback commented Jan 13, 2022

can u show the index itself here

@realead
Copy link
Contributor Author

realead commented Jan 13, 2022

can u show the index itself here

it is Index([nan, None, NaT, True], dtype='object')

@jreback
Copy link
Contributor

jreback commented Jan 13, 2022

ok great so this is just a repr issue then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants