Skip to content

BUG: DataFrame from ndarray[SeriesObjects] vs PandasArray[SeriesObjects] inconsistent #43986

Closed
@jbrockmendel

Description

@jbrockmendel

  • 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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugConstructorsSeries/DataFrame/Index/pd.array Constructors

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions