Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.

Commit 254897e

Browse files
authored
2025-03-11
0 parents  commit 254897e

File tree

2 files changed

+310
-0
lines changed

2 files changed

+310
-0
lines changed

Pandas_Data_Frame.ipynb

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 3,
6+
"id": "2a7a26cb-0ebe-4e47-bb42-35a592bfc109",
7+
"metadata": {},
8+
"outputs": [
9+
{
10+
"name": "stdout",
11+
"output_type": "stream",
12+
"text": [
13+
"<class 'pandas.core.frame.DataFrame'>\n",
14+
" c0 c1 c2 c3\n",
15+
"0 1 4 7 10\n",
16+
"1 2 5 8 11\n",
17+
"2 3 6 9 12\n"
18+
]
19+
}
20+
],
21+
"source": [
22+
"import pandas as pd\n",
23+
"\n",
24+
"dict_data = {\n",
25+
" 'c0': [1, 2, 3],\n",
26+
" 'c1': [4, 5, 6],\n",
27+
" 'c2': [7, 8, 9],\n",
28+
" 'c3': [10, 11, 12]\n",
29+
"}\n",
30+
"\n",
31+
"df = pd.DataFrame(dict_data)\n",
32+
"\n",
33+
"print(type(df))\n",
34+
"print(df)"
35+
]
36+
},
37+
{
38+
"cell_type": "code",
39+
"execution_count": 5,
40+
"id": "982893e5-10af-472e-b875-058bcfa1734b",
41+
"metadata": {},
42+
"outputs": [
43+
{
44+
"name": "stdout",
45+
"output_type": "stream",
46+
"text": [
47+
" 학번 전공 연애 중\n",
48+
"김민솔 2403 디자인 1\n",
49+
"박현민 2407 게임 0\n",
50+
"박승일 2406 AI 0\n",
51+
"\n",
52+
"\n",
53+
"Index(['김민솔', '박현민', '박승일'], dtype='object')\n",
54+
"Index(['학번', '전공', '연애 중'], dtype='object')\n"
55+
]
56+
}
57+
],
58+
"source": [
59+
"df = pd.DataFrame([[2403, '디자인', 1], [2407, '게임', 0], [2406, 'AI', 0]],\n",
60+
" index=['김민솔', '박현민', '박승일'],\n",
61+
" columns=['학번', '전공', '연애 중'])\n",
62+
"\n",
63+
"print(df)\n",
64+
"print('\\n')\n",
65+
"print(df.index)\n",
66+
"print(df.columns)"
67+
]
68+
},
69+
{
70+
"cell_type": "code",
71+
"execution_count": 7,
72+
"id": "4fa47b71-3027-4110-a718-484d976cc353",
73+
"metadata": {},
74+
"outputs": [
75+
{
76+
"name": "stdout",
77+
"output_type": "stream",
78+
"text": [
79+
" number study love\n",
80+
"민솔이 2403 디자인 1\n",
81+
"현민이 2407 게임 0\n",
82+
"승일이 2406 AI 0\n",
83+
"\n",
84+
"\n",
85+
"Index(['민솔이', '현민이', '승일이'], dtype='object')\n",
86+
"Index(['number', 'study', 'love'], dtype='object')\n"
87+
]
88+
}
89+
],
90+
"source": [
91+
"df.index = ['민솔이', '현민이', '승일이']\n",
92+
"df.columns = ['number', 'study', 'love']\n",
93+
"\n",
94+
"print(df)\n",
95+
"print('\\n')\n",
96+
"print(df.index)\n",
97+
"print(df.columns)"
98+
]
99+
},
100+
{
101+
"cell_type": "code",
102+
"execution_count": 15,
103+
"id": "8ffbf492-5522-414f-aca6-b8f19723d42b",
104+
"metadata": {},
105+
"outputs": [
106+
{
107+
"name": "stdout",
108+
"output_type": "stream",
109+
"text": [
110+
" NUM study LOVE\n",
111+
"민솔 2403 디자인 1\n",
112+
"현민 2407 게임 0\n",
113+
"승일 2406 AI 0\n",
114+
"\n",
115+
"\n"
116+
]
117+
}
118+
],
119+
"source": [
120+
"print(df)\n",
121+
"print('\\n')\n",
122+
"\n",
123+
"df.rename(columns = {'number': 'NUM', 'love': 'LOVE'}, inplace = True)\n",
124+
"df.rename(index = {'민솔이': '민솔', '현민이': '현민', '승일이': '승일'}, inplace = True)"
125+
]
126+
},
127+
{
128+
"cell_type": "code",
129+
"execution_count": 34,
130+
"id": "4079e725-0f0a-46fe-8c7f-84a8e4440250",
131+
"metadata": {},
132+
"outputs": [
133+
{
134+
"name": "stdout",
135+
"output_type": "stream",
136+
"text": [
137+
" NUM LOVE\n",
138+
"민솔 2403 1\n"
139+
]
140+
}
141+
],
142+
"source": [
143+
"df.drop(columns = ['study'], inplace = True)\n",
144+
"\n",
145+
"print(df)"
146+
]
147+
}
148+
],
149+
"metadata": {
150+
"kernelspec": {
151+
"display_name": "Python [conda env:base] *",
152+
"language": "python",
153+
"name": "conda-base-py"
154+
},
155+
"language_info": {
156+
"codemirror_mode": {
157+
"name": "ipython",
158+
"version": 3
159+
},
160+
"file_extension": ".py",
161+
"mimetype": "text/x-python",
162+
"name": "python",
163+
"nbconvert_exporter": "python",
164+
"pygments_lexer": "ipython3",
165+
"version": "3.12.7"
166+
}
167+
},
168+
"nbformat": 4,
169+
"nbformat_minor": 5
170+
}

Pandas_Series.ipynb

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 3,
6+
"id": "d1ae616a-ac50-460b-85e0-e59de66727bb",
7+
"metadata": {},
8+
"outputs": [
9+
{
10+
"name": "stdout",
11+
"output_type": "stream",
12+
"text": [
13+
"<class 'pandas.core.series.Series'>\n",
14+
"a 1\n",
15+
"b 2\n",
16+
"c 3\n",
17+
"dtype: int64\n"
18+
]
19+
}
20+
],
21+
"source": [
22+
"import pandas as pd\n",
23+
"\n",
24+
"dict_data = {\n",
25+
" 'a': 1,\n",
26+
" 'b': 2,\n",
27+
" 'c': 3\n",
28+
"}\n",
29+
"\n",
30+
"sr = pd.Series(dict_data)\n",
31+
"print(type(sr))\n",
32+
"print(sr)"
33+
]
34+
},
35+
{
36+
"cell_type": "code",
37+
"execution_count": 5,
38+
"id": "0b687c1e-bed2-45c4-abc7-22e91b25c3f2",
39+
"metadata": {},
40+
"outputs": [
41+
{
42+
"name": "stdout",
43+
"output_type": "stream",
44+
"text": [
45+
"<class 'pandas.core.series.Series'>\n",
46+
"0 2025-03-11\n",
47+
"1 3.14\n",
48+
"2 GOLD\n",
49+
"3 100\n",
50+
"4 True\n",
51+
"dtype: object\n"
52+
]
53+
}
54+
],
55+
"source": [
56+
"list_data = ['2025-03-11', 3.14, 'GOLD', 100, True]\n",
57+
"\n",
58+
"sr = pd.Series(list_data)\n",
59+
"\n",
60+
"print(type(sr))\n",
61+
"print(sr)"
62+
]
63+
},
64+
{
65+
"cell_type": "code",
66+
"execution_count": 10,
67+
"id": "3fef74d0-4303-4dab-b68e-81e88f933e1b",
68+
"metadata": {},
69+
"outputs": [
70+
{
71+
"name": "stdout",
72+
"output_type": "stream",
73+
"text": [
74+
"RangeIndex(start=0, stop=5, step=1)\n",
75+
"['2025-03-11' 3.14 'GOLD' 100 True]\n"
76+
]
77+
}
78+
],
79+
"source": [
80+
"idx = sr.index\n",
81+
"val = sr.values\n",
82+
"\n",
83+
"print(idx)\n",
84+
"print(val)"
85+
]
86+
},
87+
{
88+
"cell_type": "code",
89+
"execution_count": 14,
90+
"id": "70d2c019-57bf-4777-a3c2-ed851df0c562",
91+
"metadata": {},
92+
"outputs": [
93+
{
94+
"name": "stdout",
95+
"output_type": "stream",
96+
"text": [
97+
"이름 콩보리\n",
98+
"생일 2017-11-25\n",
99+
"귀여움 1\n",
100+
"dtype: object\n"
101+
]
102+
}
103+
],
104+
"source": [
105+
"tup_data = ('콩보리', '2017-11-25', 1)\n",
106+
"sr = pd.Series(tup_data, index=['이름', '생일', '귀여움'])\n",
107+
"print(sr)"
108+
]
109+
},
110+
{
111+
"cell_type": "code",
112+
"execution_count": null,
113+
"id": "b8818c10-4a8b-4c37-8827-e29e511710b3",
114+
"metadata": {},
115+
"outputs": [],
116+
"source": []
117+
}
118+
],
119+
"metadata": {
120+
"kernelspec": {
121+
"display_name": "Python [conda env:base] *",
122+
"language": "python",
123+
"name": "conda-base-py"
124+
},
125+
"language_info": {
126+
"codemirror_mode": {
127+
"name": "ipython",
128+
"version": 3
129+
},
130+
"file_extension": ".py",
131+
"mimetype": "text/x-python",
132+
"name": "python",
133+
"nbconvert_exporter": "python",
134+
"pygments_lexer": "ipython3",
135+
"version": "3.12.7"
136+
}
137+
},
138+
"nbformat": 4,
139+
"nbformat_minor": 5
140+
}

0 commit comments

Comments
 (0)