Skip to content

FutureWarning from pandas #3602

Closed
Closed

Description

@matt-barker94

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.

Activity

  1. BjoernLudwig commented on Apr 18, 2022

    @BjoernLudwig

    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.

  2. Bass2015 commented on May 18, 2023

    @Bass2015

    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

  3. BjoernLudwig commented on May 18, 2023

    @BjoernLudwig

    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.

  4. Bass2015 commented on May 20, 2023

    @Bass2015

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

  5. JT-NHS-UHMBT commented on Aug 16, 2023

    @JT-NHS-UHMBT

    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.
    
  6. alexcjohnson commented on Aug 16, 2023

    @alexcjohnson
    Collaborator

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

  7. JT-NHS-UHMBT commented on Aug 17, 2023

    @JT-NHS-UHMBT

    @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!

  8. MKimiSH commented on Nov 30, 2023

    @MKimiSH

    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.

  9. alexcjohnson commented on Nov 30, 2023

    @alexcjohnson
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions