Skip to content

BUG: Rows are not inserted into DataFrame from lists of one element in v2.0 #52825

Open
@n-splv

Description

@n-splv

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 main branch of pandas.

Reproducible Example

texts=['abc']
languages=['en']
df = pd.DataFrame(columns=[
        'text',
        'language'
    ])
df.loc[:, 'text'] = texts
df.loc[:, 'language'] = languages

df

Issue Description

Rows are not inserted into DataFrame from lists of one element.
If I do

texts=['abc', 'def']
df = pd.DataFrame(columns=[
        'text',
        'language'
    ])
df.loc[:, 'text'] = texts

Then the rows are added.
This bug was introduced in v 2.0

Expected Behavior

As in v1.5.3:

text language
0 abc en

Installed Versions

pd.__version__ = '2.0.0'

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugConstructorsSeries/DataFrame/Index/pd.array ConstructorsDataFrameDataFrame data structureRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions