Skip to content
Advertisement

Python dataframe in one column strings delimit by comma, and in another column if pass or fail

How I can count if a country that is in more rows , has failed or passed, enter image description here

Like is

JavaScript

and the result should be like this enter image description here

JavaScript

Because Netherlands is in 4 rows , and has 3 passed and one failed.

Advertisement

Answer

Use Series.str.split with DataFrame.explode and last call crosstab:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement