Summary statistics for each group and transpose using pandas
问题 I have a dataframe like as shown below df = pd.DataFrame({'person_id': [11,11,11,11,11,11,11,11,12,12,12], 'time' :[0,0,0,1,2,3,4,4,0,0,1], 'value':[101,102,np.nan,120,143,153,160,170,96,97,99]}) What I would like to do is a) Get the summary statistics for each subject for each time point (ex: 0hr, 1hr, 2hr etc) b) Please note that NA rows shouldn't be counted as separate record/row during computing mean I was trying the below for i in df['subject_id'].unique() df[df['subject_id'].isin([i])]