Reputation: 995
In python3 I have a dataframe on pandas:
import pandas as pd
import altair as alt
nomes_dep.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 120 entries, 0 to 119
Data columns (total 3 columns):
Deputado 120 non-null object
Valor 120 non-null object
porcentagem 120 non-null float64
dtypes: float64(1), object(2)
memory usage: 2.9+ KB
Deputado Valor porcentagem
0 ITAMAR BORGES 1,225,322.51 1.60
1 CARLAO PIGNATARI 1,205,708.42 1.57
2 CAMPOS MACHADO 1,155,406.50 1.51
3 ALENCAR SANTANA BRAGA 1,149,436.08 1.50
4 FELICIANO FILHO 1,134,941.68 1.48
Column "Deputado" has names of people. And column "porcentagem" has the percentage that these people had of expenses in relation to the total of an institution
With altair I tried to make a horizontal bar chart, in the X axis the values of the column "porcentagem" and in the Y axis the names of column "Deputado":
alt.Chart(nomes_dep.reset_index().head(10), title="Deputados com maiores totais de despesas em %").mark_bar().encode(
x=alt.X("porcentagem:Q", axis=alt.Axis(title="Porcentagem", format="%s")),
y=alt.Y(
"Deputado:N",
sort=alt.SortField(field="Porcentagem", op="sum", order="descending"),
axis=alt.Axis(title="Deputados")
)
)
But in jupyter lab I had this message:
Javascript Error: t is undefined. This usually means there's a typo in your chart specification. See the JavaScript console for the full traceback.
Please, does anyone know how I can avoid this error?
Upvotes: 0
Views: 936