question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: erroneous initialization of a DataFrame with Series objects

See original GitHub issue
  • 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.


Code Sample, a copy-pastable example

x = pd.Series(["a", "b", "c"])
y = pd.Series([1, 2, 3])

pd.DataFrame(y, x)
>>>     0
>>> a NaN
>>> b NaN
>>> c NaN
pd.DataFrame(x, y)
>>>      0
>>> 1    b
>>> 2    c
>>> 3  NaN
pd.DataFrame(x.values, y.values)
>>>    0
>>> 1  a
>>> 2  b
>>> 3  c

Problem description

I would expect pd.Series objects to be valid inputs for the DataFrame constructor. If this is not the case a warning (or even raising an error) would be nice…

Output of pd.show_versions()

INSTALLED VERSIONS

commit : c7f7443c1bad8262358114d5e88cd9c8a308e8aa python : 3.9.6.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.17763 machine : AMD64 processor : AMD64 Family 25 Model 33 Stepping 0, AuthenticAMD byteorder : little LC_ALL : None LANG : en LOCALE : German_Austria.1252

pandas : 1.3.1 numpy : 1.21.1 pytz : 2021.1 dateutil : 2.8.2 pip : 21.2.1 setuptools : 49.6.0.post20210108 Cython : None pytest : 6.2.4 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : None IPython : None pandas_datareader: None bs4 : None bottleneck : None fsspec : None fastparquet : None gcsfs : None matplotlib : 3.4.2 numexpr : 2.7.3 odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyxlsb : None s3fs : None scipy : 1.7.0 sqlalchemy : None tables : 3.6.1 tabulate : None xarray : None xlrd : None xlwt : None numba : None

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
simonjayhawkinscommented, Aug 6, 2021

@tyuyoshi sure. go for it!

1reaction
tyuyoshicommented, Aug 5, 2021

Hi, can I pick this issue as my first OSS contribution?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pandas Error for creating an emptydataframe - Stack Overflow
This is only happening on the creation of an empty dataframe, is this a recently introduced bug. File "<stdin>", line 1, in <module>...
Read more >
BUG: "groupby" failed for dataframe with object-type index ...
I have a dataframe where the index is object type, and I found the error by accident. The following code is a simplified...
Read more >
pandas.Series — pandas 1.5.2 documentation
Constructing Series from a list with copy=False . Due to input data type the Series has a copy of the original data even...
Read more >
Dataframe Constructor Not Properly Called! How To Fix This ...
Often, this error arises from supplying a string that is not compatible with the data frame constructor. In other words, if you provide...
Read more >
Lazy Validation - pandera
SchemaError: expected series 'column' to have type int64, got object ... raised with a summary of the error counts and failure cases caught...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found