Skip to content

treemap AttributeError: 'DataFrame' object has no attribute 'append' #4761

Open
@StepanSushko

Description

@StepanSushko

I try to run this code of the example from the guide page

import plotly.express as px
df = px.data.tips()
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
                 values='total_bill', color='time')
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
fig.show()

but it just gives an error


File ...\Python310\lib\site-packages\plotly\express\_core.py:1637, in process_dataframe_hierarchy(args)
   [1635](.../Python310/lib/site-packages/plotly/express/_core.py:1635)     if cols:
   [1636](.../Python310/lib/site-packages/plotly/express/_core.py:1636)         df_tree[cols] = dfg[cols]
-> [1637](.../Python310/lib/site-packages/plotly/express/_core.py:1637)     df_all_trees = df_all_trees.append(df_tree, ignore_index=True)
   [1639](.../Python310/lib/site-packages/plotly/express/_core.py:1639) # we want to make sure than (?) is the first color of the sequence
   [1640](.../Python310/lib/site-packages/plotly/express/_core.py:1640) if args["color"] and discrete_color:

File c:\Users\stepa\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\generic.py:5989, in NDFrame.__getattr__(self, name)
   [5982](.../Python310/lib/site-packages/pandas/core/generic.py:5982) if (
   [5983](.../Python310/lib/site-packages/pandas/core/generic.py:5983)     name not in self._internal_names_set
   [5984](.../Python310/lib/site-packages/pandas/core/generic.py:5984)     and name not in self._metadata
   [5985](../Python310/lib/site-packages/pandas/core/generic.py:5985)     and name not in self._accessors
   [5986](.../Python310/lib/site-packages/pandas/core/generic.py:5986)     and self._info_axis._can_hold_identifiers_and_holds_name(name)
   [5987](.../Python310/lib/site-packages/pandas/core/generic.py:5987) ):
   [5988](.../Python310/lib/site-packages/pandas/core/generic.py:5988)     return self[name]
-> [5989](.../Python310/lib/site-packages/pandas/core/generic.py:5989) return object.__getattribute__(self, name)

AttributeError: 'DataFrame' object has no attribute 'append'

pandas=2.2.2
plotly.express=0.4.1
plotly=5.24.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2considered for next cyclebugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions