GroupBy

import numpy as npimport pandas as pd # 데이터 프레임 생성np.random.seed(1)df = pd.DataFrame({'key1': ['a', 'a', 'b', 'b', 'a'],'key2': ['one', 'two', 'one', 'two', 'one'],'data1': np.random.randint(0, 10, 5),'data2': np.random.randint(0, 10, 5)})print(df) key1 key2 data1 data20 a one 5 01 a two 8 12 b one 9 73 b two 5 64 a one 0 9 grouped1 = df.groupby(by='key1')print(grouped1) # DataFrameGroupBy 객체 - ..
Codezoy
'GroupBy' 태그의 글 목록