[Pandas] Pandas Cheat Sheet(Subset Observations(Rows))
Subset Observations(Rows)¶ In [1]: import pandas as pd In [2]: df = pd.DataFrame( {"a" : [4 ,5, 6, 4, 2, 4, 5, 7], "b" : [7, 8, 9, 7, 10, 3, 2, 1], "c" : [10, 11, 12, 10, 11, 14, 3, 10]}) In [3]: df Out[3]: a b c 0 4 7 10 1 5 8 11 2 6 9 12 3 4 7 10 4 2 10 11 5 4 3 14 6 5 2 3 7 7 1 10 a행에 5이상인 값을 출력합니다.¶ In [4]: df[df.a > 5] Out[4]: a b c 2 6 9 12 7 7 1 10 a행이 7이 아닌값을 출력합니다.¶ In [5]: df[df["a"] !..
2021. 5. 23.
[Pandas] Pandas Cheat Sheet(Reshaping Data)
Reshaping Data¶ In [1]: import pandas as pd import seaborn as sns melt¶ : 멜트는 행을 녹여서 컬럼으로 보낸다는 느낌의 함수입니다. In [2]: df = pd.DataFrame( [[4, 7, 10], [5, 8, 11], [6, 9, 12]], index=[1, 2, 3], columns=['a', 'b', 'c']) df Out[2]: a b c 1 4 7 10 2 5 8 11 3 6 9 12 In [3]: pd.melt(df) Out[3]: variable value 0 a 4 1 a 5 2 a 6 3 b 7 4 b 8 5 b 9 6 c 10 7 c 11 8 c 12 옵션을 지정하지 않으면 다음과 ..
2021. 5. 20.
[Pandas] Pandas Cheat Sheet (Creating DataFrames)
Creating DataFrames¶ In [1]: import pandas as pd In [2]: df = pd.DataFrame( {"a" : [4,5,6], "b" : [7,8,9], "c" : [10,11,12]}, index = [1,2,3]) In [3]: df Out[3]: a b c 1 4 7 10 2 5 8 11 3 6 9 12 In [6]: df = pd.DataFrame( [[4, 7, 10], [5, 8, 11], [6, 9, 12]], index=[1, 2, 3], columns=['a', 'b', 'c']) In [7]: df Out[7]: a b c 1 4 7 10 2 5 8 11 3 6 9 12 In [8]: df = pd.Data..
2021. 5. 16.