I did like display height number of the bar on the output of this bar graphs and also be able to include missing values on the bar graphs to be represented by zero. This my dataset:
# intialise data of lists.
data = {'Hospital_name':['Jootrh Hospital', 'Jootrh Hospital', 'Embu Hospital', 'Embu Hospital','Bungoma Hospital', 'Bungoma Hospital', 'Keru Hospital', 'Keru Hospital'],
'periodname':["18-Jul", "18-Aug", "18-Jul", "18-Aug","18-Jul", "18-Aug", "18-Jul", "18-Aug"], 'normal deliveries':[452, 458, "NAN", 45,498, 466, "NAN", 450],
'caesarian sections':[67.0, 99.0, 13.0, 13.0,60.0, 19.0, 73.0, "NAN"], 'breach delivery':[10.0, "NAN", 13.0, 137.0,100.0, "NAN", "NAN" ,197.0],
'assisted vd':["NAN", "NAN", 1.0, 37.0,1.0, "NAN", 1.0, 37.0]}
# Create DataFrame
df = pd.DataFrame(data)
df
Here is my code that displays the bar graphs but I did like to include missing values and bar height value.
import numpy as np
import matplotlib.pyplot as plt
df.set_index('periodname', inplace=True)
grouped = df.groupby('Hospital_name')
ncols=2
nrows = int(np.ceil(grouped.ngroups/ncols))
fig, axes = plt.subplots(nrows=nrows, ncols=ncols,figsize=(20,50), constrained_layout=True)
for (key, ax) in zip(grouped.groups.keys(), axes.flatten()):
grouped.get_group(key).plot(kind='bar',ax=ax, title=key)
ax.legend()
plt.show()
How can be able to include bar height value and also include missing values represented by zero on bar graphs?