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: DataFrame from ndarray[SeriesObjects] vs PandasArray[SeriesObjects] inconsistent #43986

Closed
3 tasks done
jbrockmendel opened this issue Oct 11, 2021 · 0 comments · Fixed by #45040
Closed
3 tasks done
Labels
Bug Constructors Series/DataFrame/Index/pd.array Constructors
Milestone

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Oct 11, 2021

  • 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 numpy as np
import pandas as pd

ser = pd.Series([1, 2])

arr = np.array([None, None], dtype=object)
arr[0] = ser
arr[1] = ser * 2

parr = pd.array(arr)  # <- PandasArray

>>> pd.DataFrame(arr)
                            0
0  0    1
1    2
dtype: int64
1  0    2
1    4
dtype: int64

>>> pd.DataFrame(parr)
   0  1
0  1  2
1  2  4

Issue Description

We un-nest nested data when it is in a PandasArray but not when it is in a ndarray/Index/Series. Aligning this behavior would allow us to simplify the DataFrame constructor.

Only one test where we pass a PandasArray containing Series to DataFrame: test_apply_series_on_date_time_index_aware_series

Expected Behavior

ndarray vs PandasArray should not matter here.

Installed Versions

Replace this line with the output of pd.show_versions()

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 11, 2021
@mroeschke mroeschke added Constructors Series/DataFrame/Index/pd.array Constructors and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 16, 2021
@jreback jreback added this to the 1.4 milestone Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Constructors Series/DataFrame/Index/pd.array Constructors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants