Skip to content

BUG: Creating a Series from a Series results in all NaN values #35406

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

Closed
3 tasks done
bashtage opened this issue Jul 24, 2020 · 4 comments · Fixed by #36139
Closed
3 tasks done

BUG: Creating a Series from a Series results in all NaN values #35406

bashtage opened this issue Jul 24, 2020 · 4 comments · Fixed by #36139

Comments

@bashtage
Copy link
Contributor

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

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

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


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

import numpy as np
import pandas as pd

pd.Series(pd.Series(np.random.randn(100)),index=pd.date_range("1980-1-1",periods=100,freq="D"))

output

1980-01-01   NaN
1980-01-02   NaN
1980-01-03   NaN
...

Problem description

Series accepts array-like, and Series is array-like.

Expected Output

A Series with the same values and my new index.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.7.7.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 1.0.5
numpy : 1.18.5
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 49.2.0.post20200714
Cython : 0.29.21
pytest : 5.4.3
hypothesis : None
sphinx : 3.1.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.5.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.16.1
pandas_datareader: v0.10.0dev0+6.g642bd7b
bs4 : 4.9.1
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.5.1
matplotlib : 3.2.2
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.4
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.4.3
pyxlsb : None
s3fs : None
scipy : 1.5.0
sqlalchemy : None
tables : 3.6.1
tabulate : 0.8.7
xarray : None
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : None
numba : 0.50.1

@bashtage bashtage added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 24, 2020
@bashtage
Copy link
Contributor Author

Related to #34534 but difference since that user was explicitly passing dict. Seems like the dict-like nature of Series is taking precedence over the array-like nature of Series.

@bashtage
Copy link
Contributor Author

This line from the docstring:

 If both a dict and index sequence are used, the index will override the keys found in the dict.

should be something like

If data is dict-like and index is None, then the values in the index are used to reindex the Series after it is created using the keys in the data.

@TomAugspurger
Copy link
Contributor

This is at

index : array-like or Index (1d)
Values must be hashable and have the same length as `data`.
Non-unique index values are allowed. Will default to
RangeIndex (0, 1, 2, ..., n) if not provided. If both a dict and index
sequence are used, the index will override the keys found in the
dict.
if anyone is interested in working on it.

@TAJD
Copy link
Contributor

TAJD commented Sep 5, 2020

take

TAJD pushed a commit to TAJD/pandas that referenced this issue Sep 5, 2020
TAJD pushed a commit to TAJD/pandas that referenced this issue Sep 5, 2020
…aviour precedence - meet codeformatting criteria
@jreback jreback added this to the 1.2 milestone Sep 5, 2020
jbrockmendel pushed a commit to jbrockmendel/pandas that referenced this issue Sep 8, 2020
kesmit13 pushed a commit to kesmit13/pandas that referenced this issue Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants