seeking your kind help to solve this issue i'm facing with bar_label.
import pandas as pd
import numpy as np
import datetime as dt
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure
%matplotlib inline
df1 = pd.read_csv('AsiaCases_.csv')
df1.head()
fig,ax=plt.subplots()
ax.bar(df1['Country'],df1['TotalDeaths'])
ax.bar_label(df1['Country'])
The error i receive:
AttributeError Traceback (most recent call last) /var/folders/dc/wq8x31k506vdg85ry9frgbyh0000gp/T/ipykernel_10666/1187241174.py in 1 fig,ax=plt.subplots() 2 ax.bar(df1['Country'],df1['TotalDeaths']) ----> 3 ax.bar_label(df1['Country'])
~/opt/anaconda3/lib/python3.8/site-packages/matplotlib/axes/_axes.py in bar_label(self, container, labels, fmt, label_type, padding, **kwargs) 2604 _api.check_in_list(['edge', 'center'], label_type=label_type) 2605 -> 2606 bars = container.patches 2607 errorbar = container.errorbar 2608 datavalues = container.datavalues
~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py in getattr(self, name) 5485 ): 5486 return self[name] -> 5487 return object.getattribute(self, name) 5488 5489 def setattr(self, name: str, value) -> None:
AttributeError: 'Series' object has no attribute 'patches'
I has worked before. Somehow, the barchart plots, but the bar_label stopped working.