Skip to content

Commit 0062f91

Browse files
committed
<add>: add samples
- add sample pd.py
1 parent 4cbfc01 commit 0062f91

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

PandasPractice/pd.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
print(type(idx)) # pandas.core.indexes.range.RangeIndex
6666
'''
6767

68-
'''
68+
6969
# two-dimensional python list to Dataframe
7070
df = pd.DataFrame([[22,'남','덕영중'], [17,'여','수리중']], index=['학생1','학생2'], columns=['age','성별','학교'])
7171
print(df)
@@ -81,4 +81,15 @@
8181
print(type(df.index)) # pandas.core.indexes.base.Index
8282
print(df.columns)
8383
print(type(df.columns)) # pandas.core.indexes.base.Index
84-
'''
84+
85+
df.rename(columns={'나이': 'age', 'gender': 'gender', '소속': 'school'}, inplace=True)
86+
df2 = df.rename(columns={'나이': 'age', 'gender': 'gender', '소속': 'school'})
87+
# 기본적으로 rename 메서드는 새로운 df 객체를 반환한다. inplace=True 옵션으로 원본 객체 내에서 값을 대체할 수 있다.
88+
print(df)
89+
print(df2)
90+
print(type(df))
91+
print('id of df :', id(df))
92+
print('id of df2 :', id(df2))
93+
94+
95+
print(df == df2)?

PandasPractice/pd_calculate.py

Whitespace-only changes.

0 commit comments

Comments
 (0)