{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# 04. 머신러닝 \n\n탐색적 데이터 분석 과정에서 데이터 시각화는 데이터의 특성을 드러내는 수단      \n**😎데이터 시각화를 통해 특성을 찾아보자!**\n","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np \nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\ntitanic = sns.load_dataset('titanic')\nprint(titanic.shape)\n\n#titanic = pd.read_csv(\"/kaggle/input/titanic/train.csv\")\ntitanic.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T12:50:07.156895Z","iopub.execute_input":"2022-07-16T12:50:07.157537Z","iopub.status.idle":"2022-07-16T12:50:07.189236Z","shell.execute_reply.started":"2022-07-16T12:50:07.157489Z","shell.execute_reply":"2022-07-16T12:50:07.187717Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"titanic.info()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:33:38.042565Z","iopub.execute_input":"2022-07-16T02:33:38.042963Z","iopub.status.idle":"2022-07-16T02:33:38.072866Z","shell.execute_reply.started":"2022-07-16T02:33:38.042904Z","shell.execute_reply":"2022-07-16T02:33:38.071027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"titanic.describe()\n#info, describe 차이는? \n# info는 말 그래도 정보, 결측치의 개수나 데이터 타입을 알려주고\n# describe는 데이터의 통계량을 정리해서 보여준다.\n\n#Q : age를 보면 최솟값 0.42 등이 보인다. 왜 소수 나이가 있을까? 어떻게 해석해야할까?","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:33:41.470275Z","iopub.execute_input":"2022-07-16T02:33:41.470654Z","iopub.status.idle":"2022-07-16T02:33:41.508294Z","shell.execute_reply.started":"2022-07-16T02:33:41.470622Z","shell.execute_reply":"2022-07-16T02:33:41.507346Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"titanic.describe(include='all')","metadata":{"execution":{"iopub.status.busy":"2022-07-16T12:17:56.012946Z","iopub.execute_input":"2022-07-16T12:17:56.013369Z","iopub.status.idle":"2022-07-16T12:17:56.076055Z","shell.execute_reply.started":"2022-07-16T12:17:56.013333Z","shell.execute_reply":"2022-07-16T12:17:56.074898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data = titanic, x = 'age')#구간의 개수 auto(20개)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:34:31.317800Z","iopub.execute_input":"2022-07-16T02:34:31.318358Z","iopub.status.idle":"2022-07-16T02:34:31.608226Z","shell.execute_reply.started":"2022-07-16T02:34:31.318306Z","shell.execute_reply":"2022-07-16T02:34:31.606767Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data = titanic, x = 'age', bins =40)\n#여기서 bins는 구간의 개수","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:35:34.955370Z","iopub.execute_input":"2022-07-16T02:35:34.955782Z","iopub.status.idle":"2022-07-16T02:35:35.268086Z","shell.execute_reply.started":"2022-07-16T02:35:34.955746Z","shell.execute_reply":"2022-07-16T02:35:35.266516Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"## aa : 9명만 샘플링\naa = titanic.iloc[:9,:]\naa[aa.pclass==1].age.mean() # 42.333\naa[aa.pclass==3].age.mean() # 22.4\n\nsns.barplot(data = aa, x = 'class', y = 'age', ci=None) # ci=None 하면 신뢰구간 출력 안됨\nsns.barplot(data = aa, x = 'class', y = 'age', ci=90) # ci=None 하면 신뢰구간 출력 안됨\nsns.barplot(data = titanic, x = 'class', y = 'age',errwidth=10) # ci=None 하면 신뢰구간 출력 안됨\n\n#bootstrapping\n#https://elizavetalebedeva.com/bootstrapping-confidence-intervals-the-basics/ ","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:35:45.932805Z","iopub.execute_input":"2022-07-16T02:35:45.933240Z","iopub.status.idle":"2022-07-16T02:35:46.297128Z","shell.execute_reply.started":"2022-07-16T02:35:45.933203Z","shell.execute_reply":"2022-07-16T02:35:46.296010Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.barplot(data = titanic, x = 'class', y = 'age')\n#titanic\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:35:58.885854Z","iopub.execute_input":"2022-07-16T02:35:58.886299Z","iopub.status.idle":"2022-07-16T02:35:59.165833Z","shell.execute_reply.started":"2022-07-16T02:35:58.886261Z","shell.execute_reply":"2022-07-16T02:35:59.164673Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"titanic[titanic.age==0.42] #뭐지?","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:36:50.914497Z","iopub.execute_input":"2022-07-16T02:36:50.914935Z","iopub.status.idle":"2022-07-16T02:36:50.936050Z","shell.execute_reply.started":"2022-07-16T02:36:50.914874Z","shell.execute_reply":"2022-07-16T02:36:50.934741Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = titanic[titanic.age.notna()]\ndf[df.age%1!=0]#age가 왜 정수가 아닌지?\n# A : 이것만 놓고 보니까 나이를 개월까지 측정한 것으로 보임. 0.83은 10개월(8/12)\n# Q : 분석과정에서 개월수는 중요하지 않을 것 같으니 반올림하거나 버림해도 괜찮지 않을까?","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:37:04.528270Z","iopub.execute_input":"2022-07-16T02:37:04.529221Z","iopub.status.idle":"2022-07-16T02:37:04.566807Z","shell.execute_reply.started":"2022-07-16T02:37:04.529175Z","shell.execute_reply":"2022-07-16T02:37:04.565654Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"titanic.age.max(), titanic.age.min()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:37:37.438034Z","iopub.execute_input":"2022-07-16T02:37:37.438433Z","iopub.status.idle":"2022-07-16T02:37:37.446179Z","shell.execute_reply.started":"2022-07-16T02:37:37.438400Z","shell.execute_reply":"2022-07-16T02:37:37.444984Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#추가 ### 히스토그램에서 계급의 개수가 아니라 계급의 크기를 고정하려면?\nsns.histplot(data = titanic, x = 'age', binwidth = 10, binrange = (0, 80))","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:39:47.291556Z","iopub.execute_input":"2022-07-16T02:39:47.292388Z","iopub.status.idle":"2022-07-16T02:39:47.507489Z","shell.execute_reply.started":"2022-07-16T02:39:47.292342Z","shell.execute_reply":"2022-07-16T02:39:47.506266Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data = titanic, x = 'age', hue = 'alive')\nplt.show()\nsns.histplot(data = titanic, x = 'age', hue = 'alive', binrange=[0,80])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:39:52.774319Z","iopub.execute_input":"2022-07-16T02:39:52.774750Z","iopub.status.idle":"2022-07-16T02:39:53.433255Z","shell.execute_reply.started":"2022-07-16T02:39:52.774712Z","shell.execute_reply":"2022-07-16T02:39:53.431994Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#누적으로 그리\nsns.histplot(data = titanic, x = 'age', hue = 'alive', multiple = 'stack', binrange = (0,80) )\n# 비교해서 보기에는 이게 더 편한 것 같다.","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:41:02.899709Z","iopub.execute_input":"2022-07-16T02:41:02.900133Z","iopub.status.idle":"2022-07-16T02:41:03.258064Z","shell.execute_reply.started":"2022-07-16T02:41:02.900099Z","shell.execute_reply":"2022-07-16T02:41:03.256970Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data = titanic, x = \"age\", binrange = (0,80) )\nplt.show()\n# kdeplot(kernel density estimation), 커널 밀도 추정 함수 그래프, 히스토그램을 매끄럽게 연결(많이 쓰진 않음)\nsns.kdeplot(data = titanic, x = \"age\" )\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:41:20.785309Z","iopub.execute_input":"2022-07-16T02:41:20.785714Z","iopub.status.idle":"2022-07-16T02:41:21.218380Z","shell.execute_reply.started":"2022-07-16T02:41:20.785679Z","shell.execute_reply":"2022-07-16T02:41:21.217255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.histplot(data = titanic, x = 'age', hue = 'alive', multiple = 'stack')\nplt.show()\nsns.kdeplot(data = titanic, x = 'age', hue = 'alive', multiple = 'stack')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:41:38.203670Z","iopub.execute_input":"2022-07-16T02:41:38.204102Z","iopub.status.idle":"2022-07-16T02:41:38.761869Z","shell.execute_reply.started":"2022-07-16T02:41:38.204066Z","shell.execute_reply":"2022-07-16T02:41:38.760677Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#displot, 분포도, 뒤에 kind = 'kde' 추가하면 kdeplot가능, 없으면 히스토그램\nsns.displot(data = titanic, x = \"age\", kind = 'kde')\nplt.show()\nsns.displot(data = titanic, x = \"age\", kde = True)\nplt.show()\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:41:49.570395Z","iopub.execute_input":"2022-07-16T02:41:49.570761Z","iopub.status.idle":"2022-07-16T02:41:50.294418Z","shell.execute_reply.started":"2022-07-16T02:41:49.570729Z","shell.execute_reply":"2022-07-16T02:41:50.293662Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.kdeplot(data = titanic, x= \"age\")\nsns.rugplot(data = titanic, x= \"age\")\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:41:58.539687Z","iopub.execute_input":"2022-07-16T02:41:58.540060Z","iopub.status.idle":"2022-07-16T02:41:58.774397Z","shell.execute_reply.started":"2022-07-16T02:41:58.540029Z","shell.execute_reply":"2022-07-16T02:41:58.773212Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#rugplot이 뭔지 모르겠음.. 데이터 줄여서 확인해보기\ntitanic.shape # 891*12\ntitanic_s = titanic[:10] #10개 데이터만 살펴보기\nsns.countplot(data = titanic_s, x= \"age\")\nplt.show()\nsns.histplot(data = titanic_s, x= \"age\")\nplt.show()\nsns.kdeplot(data = titanic_s, x= \"age\")\nsns.rugplot(data = titanic_s, x= \"age\")\nplt.show()\ntitanic_s.age\n\n#countplot이 수치형 자료를 그냥 막대그래프로 나타내는데 비해 러그플럿은 히스토그램 상에서 그 정확한 위치를 보여주는데 의미가 있는 것 같음.","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:42:43.418358Z","iopub.execute_input":"2022-07-16T02:42:43.419691Z","iopub.status.idle":"2022-07-16T02:42:44.037742Z","shell.execute_reply.started":"2022-07-16T02:42:43.419646Z","shell.execute_reply":"2022-07-16T02:42:44.036564Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data = titanic_s, x= \"age\")\nplt.show()\nsns.rugplot(data = titanic_s, x= \"age\")#, expand_margins = 2)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:43:09.239842Z","iopub.execute_input":"2022-07-16T02:43:09.240929Z","iopub.status.idle":"2022-07-16T02:43:09.623816Z","shell.execute_reply.started":"2022-07-16T02:43:09.240872Z","shell.execute_reply":"2022-07-16T02:43:09.622653Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#barplot\nsns.barplot(x = 'class', y = 'fare', data = titanic, ci='sd')#class별 운임\nplt.show()\n#막대 높이는 평균 운임, 검은색 세로줄이 오차막대(신뢰구간)\n#등급이 높을수록 평균운임이 비싸고(당연), 신뢰구간이 넓어진다(?)\nfor i in range(3):\n    print(titanic[titanic['pclass']==i+1].fare.std())","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:41:11.763164Z","iopub.execute_input":"2022-07-16T03:41:11.763725Z","iopub.status.idle":"2022-07-16T03:41:12.020045Z","shell.execute_reply.started":"2022-07-16T03:41:11.763673Z","shell.execute_reply":"2022-07-16T03:41:12.018333Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"왜 신뢰구간이 등급이 높을수록 넓어지는거...","metadata":{}},{"cell_type":"code","source":"sns.histplot(data = titanic[titanic.pclass ==1], x = \"fare\")","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:43:28.247961Z","iopub.execute_input":"2022-07-16T02:43:28.248735Z","iopub.status.idle":"2022-07-16T02:43:28.502197Z","shell.execute_reply.started":"2022-07-16T02:43:28.248692Z","shell.execute_reply":"2022-07-16T02:43:28.501343Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"titanic.loc[(titanic.pclass ==1) & (titanic.fare <20)]\n# fare가 잘못 기입된 부분도 있는 것 같음. 전처리가 더 필요한 부분\n# Q : 혼자 탔고 나이대가 비슷한걸로 봐서는 선원인가?\n# 요금 차이가 극명할 수도 있을 것 같기한데..","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:47:27.219484Z","iopub.execute_input":"2022-07-16T02:47:27.219857Z","iopub.status.idle":"2022-07-16T02:47:27.242001Z","shell.execute_reply.started":"2022-07-16T02:47:27.219827Z","shell.execute_reply":"2022-07-16T02:47:27.241145Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df=titanic.loc[titanic.pclass ==1]\ndf.groupby(['embarked'])['fare'].mean()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T12:54:54.518541Z","iopub.execute_input":"2022-07-16T12:54:54.518908Z","iopub.status.idle":"2022-07-16T12:54:54.536678Z","shell.execute_reply.started":"2022-07-16T12:54:54.518877Z","shell.execute_reply":"2022-07-16T12:54:54.535518Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = (20, 4))\nsns.histplot(data = titanic,  x = \"fare\", hue = \"pclass\")\nplt.show()\n\nplt.figure(figsize = (20, 4))\nsns.kdeplot(data = titanic,  x = \"fare\", hue = \"pclass\")\nplt.show()\n\n#표준편차 영향\nfor i in range(1, 4):\n    print(\"등급 {}일 때 표준편차:{}\".format(i,round(titanic[titanic.pclass ==i].fare.std(), 2)))","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:49:21.428969Z","iopub.execute_input":"2022-07-16T02:49:21.429446Z","iopub.status.idle":"2022-07-16T02:49:22.632042Z","shell.execute_reply.started":"2022-07-16T02:49:21.429408Z","shell.execute_reply":"2022-07-16T02:49:22.631212Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#pointplot : 한 화면에 여러 그래프를 그릴 때 \nsns.pointplot(x = 'pclass', y = \"fare\", data = titanic)\nplt.show()\n\n#boxplot : five-number summary, 최솟값, q1, q2(median), q3, 최댓값\nsns.boxplot(x = 'pclass', y = 'age', data = titanic)\nplt.show() # 5요약수치 한번에 알고 싶을 때\n\n#violinplot : boxplot+kdeplot\nsns.violinplot(x = 'pclass', y = 'age', data = titanic)\nplt.show() # 분포 양상을 알고 싶을 떄","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:49:39.263407Z","iopub.execute_input":"2022-07-16T02:49:39.263826Z","iopub.status.idle":"2022-07-16T02:49:39.958459Z","shell.execute_reply.started":"2022-07-16T02:49:39.263790Z","shell.execute_reply":"2022-07-16T02:49:39.957618Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.boxplot(x = 'fare', data = titanic)\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:49:51.080628Z","iopub.execute_input":"2022-07-16T02:49:51.081060Z","iopub.status.idle":"2022-07-16T02:49:51.254621Z","shell.execute_reply.started":"2022-07-16T02:49:51.081019Z","shell.execute_reply":"2022-07-16T02:49:51.253325Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.violinplot(x = 'pclass', y = 'fare', data = titanic)\nplt.show() \n\nsns.violinplot(x = 'pclass', y = \"age\", hue = 'sex', data = titanic, split = True)","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:49:55.753484Z","iopub.execute_input":"2022-07-16T02:49:55.754160Z","iopub.status.idle":"2022-07-16T02:49:56.218944Z","shell.execute_reply.started":"2022-07-16T02:49:55.754118Z","shell.execute_reply":"2022-07-16T02:49:56.217805Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#countplot : 범주형 데이터의 개수 확인\nsns.countplot(x=\"pclass\", data = titanic)\nplt.show()\n\nsns.countplot(y=\"pclass\", data = titanic)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:50:09.844715Z","iopub.execute_input":"2022-07-16T02:50:09.845141Z","iopub.status.idle":"2022-07-16T02:50:10.161561Z","shell.execute_reply.started":"2022-07-16T02:50:09.845102Z","shell.execute_reply":"2022-07-16T02:50:10.160394Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#pie graph, sns에서는 원그래프 지원하지 않음\nx = [10, 30, 60]\nlabels = ['A', 'B','C']\nplt.pie(x=x, labels = labels, autopct = '%.1f%%', )\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:50:12.924540Z","iopub.execute_input":"2022-07-16T02:50:12.925672Z","iopub.status.idle":"2022-07-16T02:50:13.022640Z","shell.execute_reply.started":"2022-07-16T02:50:12.925629Z","shell.execute_reply":"2022-07-16T02:50:13.021245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#titanic 데이터 feature 별 비율 나타내기\nf = \"alive\"#feature 입력\n\nx = []\nlabels = titanic[f].unique()\nfor i in labels:\n    x.append(titanic[titanic[f]==i][f].count())\nplt.pie(x=x, labels = labels, autopct = '%.1f%%', )\nplt.show()\ntitanic\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T02:50:20.253358Z","iopub.execute_input":"2022-07-16T02:50:20.254194Z","iopub.status.idle":"2022-07-16T02:50:20.380595Z","shell.execute_reply.started":"2022-07-16T02:50:20.254148Z","shell.execute_reply":"2022-07-16T02:50:20.379355Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:04:49.846197Z","iopub.execute_input":"2022-07-16T03:04:49.846623Z","iopub.status.idle":"2022-07-16T03:04:49.851135Z","shell.execute_reply.started":"2022-07-16T03:04:49.846584Z","shell.execute_reply":"2022-07-16T03:04:49.850287Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# for dirname, _, filenames in os.walk('/kaggle/input/air-passengers'):\n#     for filename in filenames:\n#         print(os.path.join(dirname, filename))\n\n# flights = pd.read_csv(\"//kaggle/input/air-passengers/AirPassengers.csv\")\n\n# year, month = [], []\n# for i in flights.Month:\n#     year.append(i[:4])\n#     month.append(i[-2:])\n# flights['year'] = year\n# flights['month'] = month\n# flights = flights.drop('Month', axis=1)\n# flights.columns = ['passengers', 'year', 'month']\n# flights = flights[['year', 'month', 'passengers']]\n# flights","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:07:35.612643Z","iopub.execute_input":"2022-07-16T03:07:35.613930Z","iopub.status.idle":"2022-07-16T03:07:35.619384Z","shell.execute_reply.started":"2022-07-16T03:07:35.613857Z","shell.execute_reply":"2022-07-16T03:07:35.618236Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"flights = sns.load_dataset('flights')","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:07:39.857192Z","iopub.execute_input":"2022-07-16T03:07:39.857876Z","iopub.status.idle":"2022-07-16T03:07:39.869640Z","shell.execute_reply.started":"2022-07-16T03:07:39.857825Z","shell.execute_reply":"2022-07-16T03:07:39.868368Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"flights_pivot = flights.pivot(index = 'month', columns = 'year', values = 'passengers')\ndisplay(flights_pivot)\nsns.heatmap(data = flights_pivot, cmap= 'Reds')","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:07:42.438695Z","iopub.execute_input":"2022-07-16T03:07:42.439110Z","iopub.status.idle":"2022-07-16T03:07:42.777987Z","shell.execute_reply.started":"2022-07-16T03:07:42.439071Z","shell.execute_reply":"2022-07-16T03:07:42.777164Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"flights","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:07:48.562870Z","iopub.execute_input":"2022-07-16T03:07:48.563273Z","iopub.status.idle":"2022-07-16T03:07:48.577213Z","shell.execute_reply.started":"2022-07-16T03:07:48.563237Z","shell.execute_reply":"2022-07-16T03:07:48.576428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#\nplt.scatter(flights.year, flights.passengers)\nplt.show()\n#jitter : 중첩된 점들을 흩뿌리기\nsns.stripplot(data =flights, x=\"year\", y=\"passengers\", jitter=0.3, size=5)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:07:51.726574Z","iopub.execute_input":"2022-07-16T03:07:51.727210Z","iopub.status.idle":"2022-07-16T03:07:52.167815Z","shell.execute_reply.started":"2022-07-16T03:07:51.727169Z","shell.execute_reply":"2022-07-16T03:07:52.166748Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"flights.pivot(columns = 'year', index = 'month').mean()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:08:01.974513Z","iopub.execute_input":"2022-07-16T03:08:01.975185Z","iopub.status.idle":"2022-07-16T03:08:01.988407Z","shell.execute_reply.started":"2022-07-16T03:08:01.975144Z","shell.execute_reply":"2022-07-16T03:08:01.987642Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.lineplot(x = 'year', y = 'passengers', data = flights, ci=99) #95%신뢰구간","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:08:04.912891Z","iopub.execute_input":"2022-07-16T03:08:04.913324Z","iopub.status.idle":"2022-07-16T03:08:05.454960Z","shell.execute_reply.started":"2022-07-16T03:08:04.913287Z","shell.execute_reply":"2022-07-16T03:08:05.453902Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for dirname, _, filenames in os.walk('/kaggle/input/tipping'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:11:58.165657Z","iopub.execute_input":"2022-07-16T03:11:58.166097Z","iopub.status.idle":"2022-07-16T03:11:58.174797Z","shell.execute_reply.started":"2022-07-16T03:11:58.166056Z","shell.execute_reply":"2022-07-16T03:11:58.174038Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tips = pd.read_csv(\"//kaggle/input/tipping/tips.csv\")\ntips","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:12:12.488562Z","iopub.execute_input":"2022-07-16T03:12:12.488937Z","iopub.status.idle":"2022-07-16T03:12:12.514551Z","shell.execute_reply.started":"2022-07-16T03:12:12.488885Z","shell.execute_reply":"2022-07-16T03:12:12.513547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.scatterplot(x = 'total_bill', y='tip', data = tips)\nplt.show()\n\nsns.scatterplot(x = 'total_bill', y='tip', hue = 'time',data = tips)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:12:15.233348Z","iopub.execute_input":"2022-07-16T03:12:15.234271Z","iopub.status.idle":"2022-07-16T03:12:15.659066Z","shell.execute_reply.started":"2022-07-16T03:12:15.234231Z","shell.execute_reply":"2022-07-16T03:12:15.657994Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.regplot(x = 'total_bill', y = 'tip', data = tips[tips.time==\"Dinner\"])\nsns.regplot(x = 'total_bill', y = 'tip', data = tips[tips.time==\"Lunch\"])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-07-16T03:12:25.285264Z","iopub.execute_input":"2022-07-16T03:12:25.285663Z","iopub.status.idle":"2022-07-16T03:12:25.700753Z","shell.execute_reply.started":"2022-07-16T03:12:25.285628Z","shell.execute_reply":"2022-07-16T03:12:25.699646Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}}]}