Skip to content Skip to sidebar Skip to footer

Data Frame Group Id, Create Value: Count In Column

Given the following sample dataset: import numpy as np import pandas as pd df1 = (pd.DataFrame(np.random.randint(3, size=(5, 4)), columns=('ID', 'X1', 'X2', 'X3'))) print(df1)

Solution 1:

1021  [One:3, Two:3]

should be [One: 2, Two:3] instead right? Considering that:

1 : [One,Two]
  0 :None2 : [Two]
  1 : [One, Two]

and you want a total counter of each key in the row ?

Please help me understand the intuition behind [One:3, Two:3] in case I am missing anything here, but your question should be easy to solve otherwise

Post a Comment for "Data Frame Group Id, Create Value: Count In Column"