Task: To check if a column in a .csv file has either the string "Sales" or "Products". If so it would count them and add it to the cell in the csv file.
Issue being returned: `ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
merger = dm[["GEO", "JOB_CATEGORY"]].copy()
global geos
geos = ["Asia", "Europe", "North America"]
#Each GEO is filtered via JOB CATEGORY to only select the role "Sales" and "Products"
cell = ["B2", "C2", "D2", "E2", "F2" , "G2" , "H2", "I2"]
for i in range(len(geos)):
sheet[cell[i]] = merger[(merger.JOB_CATEGORY == "Sales" or merger.JOB_CATEGORY == "Products") & (merger.GEO == geos[i])].count()['GEO']
sheet['J2'] = merger[(merger.JOB_CATEGORY == "Sales" or merger.JOB_CATEGORY == "Products")].count()['GEO']
Aucun commentaire:
Enregistrer un commentaire