I have a dataframe with 5354 rows and 29 columns. The rows represent the dates, while the columns represent company names.
I have produced a pie chart using plotly to represent the relative share of each company using the following code:
values = df5.loc['2021-12-31'] fig = go.Figure(data=[go.Pie(labels=df5.columns, values=values)])
Now i want to to generate a plot that group all values that are less than 2% of the total row values to “Others” category (for example, on 31/12/2021, all values that are less than 2% of the row total should be classified as ‘Others’).
a = df5.iloc[:, 1:].div(df5.sum(axis=1), axis=0)
I have created a new dataframe ‘a’, which is the percentage of each column but not sure of the next steps. Any thoughts on this?