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: Get deprecation warning from Series constructor #55228

Closed
2 of 3 tasks
rikardn opened this issue Sep 21, 2023 · 3 comments · Fixed by #55395
Closed
2 of 3 tasks

BUG: Get deprecation warning from Series constructor #55228

rikardn opened this issue Sep 21, 2023 · 3 comments · Fixed by #55395
Labels
Bug Warnings Warnings that appear or should be added to pandas
Milestone

Comments

@rikardn
Copy link

rikardn commented Sep 21, 2023

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

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

@rikardn rikardn added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 21, 2023
@lithomas1 lithomas1 added Blocker Blocking issue or pull request for an upcoming release Warnings Warnings that appear or should be added to pandas and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 21, 2023
@lithomas1 lithomas1 added this to the 2.1.2 milestone Sep 21, 2023
@lithomas1
Copy link
Member

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

is the offending line.

cc @jbrockmendel

@jbrockmendel
Copy link
Member

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

@paulreece
Copy link
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.

@lithomas1 lithomas1 modified the milestones: 2.1.2, 2.1.3 Oct 26, 2023
@jorisvandenbossche jorisvandenbossche removed the Blocker Blocking issue or pull request for an upcoming release label Oct 27, 2023
@jorisvandenbossche jorisvandenbossche modified the milestones: 2.1.3, 2.1.4 Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Warnings Warnings that appear or should be added to pandas
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants