I have a dataframe created from a csv file. I created calculations to convert column values to percentages.
Then I converted the columns to lists and now I want to create a stacked bar chart using the lists, but I can't.
What is the best way forward?
def funcaoStackedBar(data,valor, colX, colStacked):
data[f'perc_{valor}'] = data.apply(lambda x: (x[f'{valor}'] / x[f'{valor}']/ data[f'{valor}'].sum())*100, axis = 1)
tps = data.pivot_table(values=f'perc_{valor}', index=colX, columns=colStacked, aggfunc='sum')
tps = tps.div(tps.sum(1), axis=0)
tps.plot(kind='bar', stacked=True, figsize=(20,10), title='Gráfico de Barras Empilhadas')