I've tried to create a graph for the dates column in python with seaborn. I'm getting the error bellow. Do you have any idea how to fix it?
----> 4 if df['MS_Date']=="s.xii" or df['MS_Date']=="s.xii(1)" or df['MS_Date']=="s.xii(2)" or df['MS_Date']=="s.xii(in)" or df['MS_Date']=="s.xii(ex)" or df['MS_Date']=="s.xii(med)": 5 df['MS_Date']== "12th century" 6 if df['MS_Date']=="s.xii/xiii" or df['MS_Date']=="s.xii/xiii":
~\anaconda\lib\site-packages\pandas\core\generic.py in nonzero(self)
1477
1478 By ambiguous, we mean that it matches both a level of the input
-> 1479 axis
and a label of the other axis.
1480
1481 Parameters
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
The code:
if df['MS_Date']=="s.xii" or df['MS_Date']=="s.xii(1)" or df['MS_Date']=="s.xii(2)" or df['MS_Date']=="s.xii(in)" or df['MS_Date']=="s.xii(ex)" or df['MS_Date']=="s.xii(med)":
df['MS_Date']== "12th century"
if df['MS_Date']=="s.xii/xiii" or df['MS_Date']=="s.xii/xiii":
df['MS_Date']=="12 & 13 century"
if df['MS_Date']=="s.xiii" or df['MS_Date']=="s.xiii(1)" or df['MS_Date']=="s.xiii(2)" or df['MS_Date']=="s.xiii(in)" or df['MS_Date']=="s.xiii(ex)" or df['MS_Date']=="s.xiii(med)":
df['MS_Date']=="13 century"
if df['MS_Date']=="s.xiii/s.xiv" or df['MS_Date']=="s.xiii/xiv":
df['MS_Date']=="13 & 14 century"
if df['MS_Date']=="s.xiii/s.xv":
df['MS_Date']=="13 & 15 century"
if df['MS_Date']=="s.xiv" or df['MS_Date']=="s.xiv(1)" or df['MS_Date']=="s.xiv(2)" or df['MS_Date']=="s.xiv(in)" or df['MS_Date']=="s.xiv(ex)" or df['MS_Date']=="s.xiv(med)":
df['MS_Date']=="14th century"
if df['MS_Date']=="s.xiv/xv":
df['MS_Date']== "14 & 15 century"
if df['MS_Date']=="s.xv" or df['MS_Date']=="s.xv(1)" or df['MS_Date']=="s.xv(2)" or df['MS_Date']=="s.xv(in)" or df['MS_Date']=="s.xv(ex)" or df['MS_Date']=="s.xv(med)" :
df['MS_Date']=="15th century"
if df['MS_Date']=="s.xv/xvi":
df['MS_Date']== "15 & 16 century"
if df['MS_Date']=="xvi" or df['MS_Date']=="s.xvi(in)":
df['MS_Date']== "16 century"
else:
df['MS_Date']=="unknown"
import seaborn as sns
sns.set(style="whitegrid")
fig, ax = plt.subplots()
fig.set_size_inches(25, 12)
sns.countplot(x='MS_Date', data=df, order=df['MS_Date'].value_counts().index, palette="Greens_d")
sns.set(style="white")
dfnew=nbl.describe(include=['object'])
num=dfnew.loc['count','MS_Date']
# df.iloc[0]['MS_Date']
ax.set_title('Distrubution of all manuscripts '+str(num)+' manuscripts')