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:

1   0   2   1  [One: 3, Two: 3]

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

  1 : [One,Two]
  0 : None
  2 : [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"