mardi 28 avril 2020

Detect the presence or absence of a string in a pattern with Python

I'm a beginner in python coding. I need a hand to find an elegant way to do this:

I've got the following dataframe :

  pattern  nb
1   a,b,c  150
2       b  100
3     c,b  30
4       c  10

According to the presence of string, I want a dataframe like that :

  pattern   nb    a    b     c
1   a,b,c   150   150  150   150
2       b   100   0    100   0
3     c,b   30    0    30    30
4       c   10    0    0     10

Many thanks in advance.

Greetings from France

Arnaud

Aucun commentaire:

Enregistrer un commentaire