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

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

Open
StepanSushko opened this issue Sep 11, 2024 · 2 comments
Open
Labels
bug something broken P2 considered for next cycle

Comments

@StepanSushko
Copy link

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

@gvwilson gvwilson added bug something broken P2 considered for next cycle labels Sep 11, 2024
@SSivakumar12
Copy link

Interesting...when running it in google collab with the specified package versions that you had, it appears to work for me and didn't raise the error you mentioned. see here

Looking more specifically at the error, I believe the DataFrame.append() has been depreciated in favour of DataFrame.concat() so replacing it accordingly on line 1637 should fix this but would be interested to see if this issue occurs for others.

@LiamConnors
Copy link
Member

Hi @StepanSushko, what kind of environment are you running this in? Is it a notebook?
This was fixed a while ago in Plotly, so it feels like the environment might be picking up the wrong version.

Are the versions you mention what you see when you run pip list?

If you are in a notebook, what does this output?

import plotly
plotly.__version__

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P2 considered for next cycle
Projects
None yet
Development

No branches or pull requests

4 participants