Skip to content

BUG: Get deprecation warning from Series constructor #55228

Closed

Description

@rikardn

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

import pandas as pd

ind1 = pd.Series([1])
ind2 = pd.Series([2])
ser = pd.Series([1.23], index=[ind1, ind2])
print(ser)

Issue Description

If trying to create a series with a multiindex from two series I get a deprecation warning with pandas 2.1.1

DeprecationWarning: Series._data is deprecated and will be removed in a future version. Use public APIs instead.

Since I am not using _data explicitly it must come from inside of pandas. The only place I have found where this could come from is in the is_all_arraylike function where there is a hasattr(val, "_data") in the cython code.

Expected Behavior

I expect no warning and at least in pandas 2.0.3 this was the case.

Installed Versions

Details

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

Activity

  1. added
    Needs TriageIssue that has not been reviewed by a pandas team member
    on Sep 21, 2023
  2. added
    BlockerBlocking issue or pull request for an upcoming release
    WarningsWarnings that appear or should be added to pandas
    and removed
    Needs TriageIssue that has not been reviewed by a pandas team member
    on Sep 21, 2023
  3. added this to the 2.1.2 milestone on Sep 21, 2023
  4. lithomas1 commented on Sep 21, 2023

    @lithomas1
    Contributor

    util.is_array(val) or hasattr(val, "_data")):

    is the offending line.

    cc @jbrockmendel

  5. jbrockmendel commented on Sep 21, 2023

    @jbrockmendel
    Member

    The hasattr check is bad. Changing it to hasattr(type(val), "_data") might avoid the warning for now?

  6. paulreece commented on Sep 21, 2023

    @paulreece
    Contributor

    I can confirm that the deprecation warning occurs on the main development branch.

    >>> import pandas as pd
    >>> ind1 = pd.Series([1])
    >>> ind2 = pd.Series([2])
    >>> ser = pd.Series([1.23], index=[ind1, ind2])
    <stdin>:1: DeprecationWarning: Series._data is deprecated and will be removed in a future version. Use public APIs instead.
  7. modified the milestones: 2.1.2, 2.1.3 on Oct 26, 2023
  8. removed
    BlockerBlocking issue or pull request for an upcoming release
    on Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugWarningsWarnings that appear or should be added to pandas

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions