1

I´m getting an issue when trying to do this graph bar and keep getting the same error

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from datetime import datetime
!pip install wbdata
import wbdata

wbdata.get_source()
wbdata.get_source()

indicador = {'SP.POP.TOTL' : 'Population total', 'SP.POP.GROW':'Population growth'}
pais = ['CRI']
df = wbdata.get_dataframe(indicador, pais)
df['date'] = df.index
pd.to_datetime(df.date)
df.reset_index(drop = True, inplace = True)
df = df[['date','Population total', 'Population growth' ]]

df.iloc[::-1].plot.bar(x = 'date', y = 'Population total', color = 'g')

plt.xticks(df['date'][::10], rotation = 'vertical')

plt.title('Total de población de Costa Rica y crecimiento')
plt.show()

the error i keep getting looks like this

error image

Abril
  • 11
  • 2

1 Answers1

0

Solved it:

df.plot.bar(x = 'date', y = 'Population total', color = 'g')
plt.xticks(ticks = df[::-1].date.iloc[::10].index.array, labels = df.date.iloc[::10])
plt.yticks(ticks = [elem * 1000000 for elem in range(1,6)] , labels = [elem * 1000000 for elem in range(1,6)] )
df2.plot.line(x = 'date', y='Population growth')



plt.title('Total de población de Costa Rica y crecimiento')
plt.xticks(df[::-1].date.iloc[::10].index.array,df.date.iloc[::10])
plt.show()
Abril
  • 11
  • 2