Answers for "column 3 but pandas count 2"

0

pandas value_counts multiple columns

In [212]:
df = pd.DataFrame(np.random.randint(0, 2, (10, 4)), columns=list('abcd'))
df.apply(pd.Series.value_counts)
Out[212]:
   a  b  c  d
0  4  6  4  3
1  6  4  6  7
Posted by: Guest on September-28-2020
0

pandas count show one column

# You can – optionally – remove the unnecessary columns and 
# keep the user_id column only:

article_read.groupby('source').count()[['user_id']]

# Change user_id as you see fit.
Posted by: Guest on May-28-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language