Skip to content

Plotly.express not working with Pandas Dataframe #4179

Closed

Description

@JS-Aibel

The example below results in an error message saying “AttributeError: 'DataFrame' object has no attribute 'append'. Did you mean: '_append'?”. The plotly example is taken from https://plotly.com/python/radar-chart/.
Running Plotly Version: 5.14.1 and Pandas Version: 2.0.1.

import plotly.express as px
import pandas as pd
df = pd.DataFrame(dict(
    r=[1, 5, 2, 2, 3],
    theta=['processing cost','mechanical properties','chemical stability',
           'thermal stability', 'device integration']))
fig = px.line_polar(df, r='r', theta='theta', line_close=True)
fig.show()

Activity

  1. Tauvic commented on Apr 29, 2023

    @Tauvic

    Yes got the same issue. Running Plotly Version: 5.14.1 and Pandas Version: 2.0.1.

    2023-04-29 17:09:37.289 Uncaught app exception
    Traceback (most recent call last):
    File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.dict)
    File "/app/resumebuilderapp/pages/3_Summary.py", line 84, in
    fig = px.line_polar(d, r='years', theta='expertise',color='proficiency',
    File "/home/appuser/venv/lib/python3.9/site-packages/plotly/express/_chart_types.py", line 998, in line_polar
    return make_figure(args=locals(), constructor=go.Scatterpolar)
    File "/home/appuser/venv/lib/python3.9/site-packages/plotly/express/_core.py", line 2173, in make_figure
    patch, fit_results = make_trace_kwargs(
    File "/home/appuser/venv/lib/python3.9/site-packages/plotly/express/_core.py", line 271, in make_trace_kwargs
    trace_data = trace_data.append(trace_data.iloc[0])
    File "/home/appuser/venv/lib/python3.9/site-packages/pandas/core/generic.py", line 5989, in getattr
    return object.getattribute(self, name)
    AttributeError: 'DataFrame' object has no attribute 'append'

  2. Satoshi-Sh commented on Apr 30, 2023

    @Satoshi-Sh

    Same here. Seems like the append function was depreciated, and it needs to be replaced by concat.

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