I'm trying to plot my dataframe using matplotlib.pyplot. I'm plotting a total of 5k plots and midway the kernel dies.
You can use this code to generate this simple dataframe:
import pandas as pd
import numpy as np
df=pd.DataFrame()
countries = ['Argentina', 'Brazil', 'Chile', 'China', 'Colombia', 'Czech Republic', 'Egypt', 'Greece', 'United Arab Emirates']
for c in countries:
df=df.append(pd.DataFrame({'date':pd.date_range(start='2001-01-01',end='2021-12-31',freq='B'),'country':c}))
df['value'] = np.random.randint(0,100,len(df))
df
Next, I'm trying to plot the value and country for each particular date.
for d in list(df.date.unique()): # For each unique date, make a plot
ax=(df.loc[df.date==d,['country','value']].set_index('country').sort_values('value')
.plot())
print(f'{d} done.')
del ax
How can I resolve this issue?