File name
Commit message
Commit date
File name
Commit message
Commit date
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "2488d73e",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "5923b769",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'year': [2018, 2019, 2020], 'sales': [350, 480, 1099]}"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data_dic = {\n",
" 'year' : [2018, 2019, 2020],\n",
" 'sales' : [350, 480, 1099]\n",
"}\n",
"data_dic"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "1919e60b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"year [2018, 2019, 2020]\n",
"sales [350, 480, 1099]\n",
"dtype: object"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ds = pd.Series(data_dic)\n",
"ds"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "dd46a777",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>year</th>\n",
" <th>sales</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2018</td>\n",
" <td>350</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2019</td>\n",
" <td>480</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2020</td>\n",
" <td>1099</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" year sales\n",
"0 2018 350\n",
"1 2019 480\n",
"2 2020 1099"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df1 = pd.DataFrame(data_dic)\n",
"df1"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "14e8c8e5",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>sales</th>\n",
" </tr>\n",
" <tr>\n",
" <th>year</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2018</th>\n",
" <td>350</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2019</th>\n",
" <td>480</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2020</th>\n",
" <td>1099</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" sales\n",
"year \n",
"2018 350\n",
"2019 480\n",
"2020 1099"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df1.set_index('year')"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "6f0a64c7",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>1반</th>\n",
" <th>2반</th>\n",
" <th>3반</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>중간고사</th>\n",
" <td>89.2</td>\n",
" <td>92.5</td>\n",
" <td>90.8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>기말고사</th>\n",
" <td>92.8</td>\n",
" <td>89.9</td>\n",
" <td>95.2</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 1반 2반 3반\n",
"중간고사 89.2 92.5 90.8\n",
"기말고사 92.8 89.9 95.2"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data2 = ['1반', '2반', '3반']\n",
"df2 = pd.DataFrame([[89.2, 92.5, 90.8], [92.8, 89.9, 95.2]], index = ['중간고사', '기말고사'], columns = data2[0:3])\n",
"df2"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "a1ea90d8",
"metadata": {},
"outputs": [],
"source": [
"df1 = pd.DataFrame([[89.2, 92.5, 90.8], [92.8, 89.9, 95.2]])"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "db0b10ea",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>89.2</td>\n",
" <td>92.5</td>\n",
" <td>90.8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>92.8</td>\n",
" <td>89.9</td>\n",
" <td>95.2</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 1 2\n",
"0 89.2 92.5 90.8\n",
"1 92.8 89.9 95.2"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df1"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "0deb3702",
"metadata": {},
"outputs": [],
"source": [
"df1.columns = {1, 2, 3}"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "069b808e",
"metadata": {},
"outputs": [],
"source": [
"df1.index = {'middle', 'final'}"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "9ee94d2c",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>middle</th>\n",
" <td>89.2</td>\n",
" <td>92.5</td>\n",
" <td>90.8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>final</th>\n",
" <td>92.8</td>\n",
" <td>89.9</td>\n",
" <td>95.2</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 1 2 3\n",
"middle 89.2 92.5 90.8\n",
"final 92.8 89.9 95.2"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df1"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "8cdb7b5f",
"metadata": {},
"outputs": [],
"source": [
"df1.to_csv('C:/Users/pc/dev/20220418/score.csv')"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "d7b41ef1",
"metadata": {},
"outputs": [],
"source": [
"df1.to_csv('C:/Users/pc/dev/20220418/score2.csv', header='False')"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "971fd233",
"metadata": {},
"outputs": [],
"source": [
"df1.to_csv('C:/Users/pc/dev/20220418/score3.csv', encoding='utf-8')"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "a3539477",
"metadata": {},
"outputs": [],
"source": [
"df1.to_csv('C:/Users/pc/dev/20220418/score4.csv', encoding='euc-kr')"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "66613fcc",
"metadata": {},
"outputs": [],
"source": [
"df1.to_csv('C:/Users/pc/dev/20220418/score5.csv', encoding='ms949')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6c64e3d3",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}