Reputation: 2917
I have a dataframe like
device_id A B C
4352d38a5c0937da 1.0 2.0
4352d38a5c0937da 1.0 2.0
4352d38a5c0937da 1.0 3.0
4352d38a5c0937da 1.0 3.0
Because the value in a column is exactly the same, so I want to groupby device_id to get the result like:
device_id A B C
4352d38a5c0937da 1.0 2.0 3.0
Can somebody help me with that. Thanks.
Upvotes: 0
Views: 48
Reputation: 5451
this groupby should do what you wanted
df = pd.DataFrame([['4352d38a5c0937da', '1.0', '2.0', 'na'], ['4352d38a5c0937da', '1.0', '2.0', 'na'], ['4352d38a5c0937da', '1.0', 'na', '3.0'], ['4352d38a5c0937da', '1.0', 'na', '3.0']], columns=('device_id', 'A', 'B', 'C'))
df.groupby("device_id").max()
Upvotes: 2