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

FutureWarning from pandas #3602

Closed
matt-barker94 opened this issue Feb 24, 2022 · 9 comments · Fixed by #3690
Closed

FutureWarning from pandas #3602

matt-barker94 opened this issue Feb 24, 2022 · 9 comments · Fixed by #3690

Comments

@matt-barker94
Copy link

matt-barker94 commented Feb 24, 2022

A future warning about pandas DataFrame.append method being deprecated in future pandas releases, and to replace with pandas.concat methods. I found this warning in plotly/plotly.py/packages/python/plotly/plotly/express/_core.py:271 but there may be other places in plotly when DataFrame.append method is used.

@BjoernLudwigPTB
Copy link
Contributor

I just stumbled across those annoying warnings as well. Seems like a good first issue to me, so I will start to work on this now. Dev environment is already set up and right now I am identifying the spots where those changes need to be applied.

I will keep you updated as soon as there is a first commit.

@Bass2015
Copy link

Hi,
@BjoernLudwigPTB @nicolaskruchten
I saw you fixed this in a commit, but I'm still getting an error when I try to use plotly.express polar charts using streamlit.
And for some reason, it makes the app crash when it's deployed, but not when it runs on localhost.

python3.10/site-packages/plotly/express/_core.py:271: FutureWarning:

The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead

This is the piece of code where it happens:

def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
    """Populates a dict with arguments to update trace

    Parameters
    ----------
    args : dict
        args to be used for the trace
    trace_spec : NamedTuple
        which kind of trace to be used (has constructor, marginal etc.
        attributes)
    trace_data : pandas DataFrame
        data
    mapping_labels : dict
        to be used for hovertemplate
    sizeref : float
        marker sizeref

    Returns
    -------
    trace_patch : dict
        dict to be used to update trace
    fit_results : dict
        fit information to be used for trendlines
    """
    if "line_close" in args and args["line_close"]:
        trace_data = trace_data.append(trace_data.iloc[0])

I upgraded plotly to version 5.14.1, and still get this error

@BjoernLudwigPTB
Copy link
Contributor

BjoernLudwigPTB commented May 18, 2023

I saw you fixed this in a commit, but I'm still getting an error […]

Oh no, I must have missed that. 😞 But it seems to be already addressed by a8af752 two weeks ago.

@Bass2015
Copy link

Yeah, I just saw it's fixed, but still unreleased. Thanx for this tools, btw!

@JT-NHS-UHMBT
Copy link

Hi, when will the fix for this be released. I am still getting the warning when using plotly.express.line_polar:

Python311\Lib\site-packages\plotly\express\_core.py:271: FutureWarning:
The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.

@alexcjohnson
Copy link
Collaborator

@JT-NHS-UHMBT - #4190 fixed this and was released in v5.15.0, what version do you have?

@JT-NHS-UHMBT
Copy link

@JT-NHS-UHMBT - #4190 fixed this and was released in v5.15.0, what version do you have?

Thanks @alexcjohnson all working now, I was using v5.11.0 - should have checked that first, silly mistake!

@MKimiSH
Copy link

MKimiSH commented Nov 30, 2023

Pandas gives another warning on groupby on categorical columns now, regarding the default values:

.../venv/lib/python3.10/site-packages/plotly/express/_core.py:2044: FutureWarning:

The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=Fals
e to retain current behavior or observed=True to adopt the future default and silence this warning.

The easy solution would be to pass observed=False to that groupby call. Not sure if that is the desired behavior, though.

@alexcjohnson
Copy link
Collaborator

@MKimiSH this was fixed in #4437 (🙇 @arcanaxion) and will be included in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants