given this dataframe is it possible to look for particular strings such as the countries that are located inside the countries list? (For example for the first index in 'Country', it has the word Japan inside it and its corresponding value will be 1). Is it possible to sum up the value that corresponds to each country? (End result: Japan: 1+3=4 USA:2 Europe:4)
countries=["Europe","USA","Japan"]
df=pd.DataFrame={'Employees':[1,2,3,4],
'Country':['Japan;Security','USA;Google',"Japan;Sega","Europe;Google"]}
print(df)
Thanks
.str.split(';')[0]then do agroupbyon the new column, use.agg({'Employees':'sum'}). This is a classic use case ofgroupby, I strongly encourage you to read the docs.