๐Ÿ“’ Today I Learn/๐Ÿ Python

์ƒ๊ด€๊ด€๊ณ„ ๊ทธ๋ž˜ํ”„ ๊ทธ๋ฆฌ๊ธฐ๐Ÿ’ฝ ํ™œ์šฉ ๋ฐ์ดํ„ฐ์…‹ - seaborn diamondsdiamonds = sns.load_dataset('diamonds')# diamonds์—์„œ numeric ๋ณ€์ˆ˜๋งŒ ์„ ํƒdiamonds2 = diamonds.select_dtypes(include='number')diamonds2.head()๐Ÿ“Š ์ƒ๊ด€๊ด€๊ณ„ ํžˆํŠธ๋งต ๊ทธ๋ฆฌ๊ธฐheatmap_diamonds = sns.heatmap(diamonds2.corr(), annot = True, cmap = 'RdPu')heatmap_diamonds.set(title='corr plot')์กฐ์ธํŠธ ๊ทธ๋ž˜ํ”„ ๊ทธ๋ฆฌ๊ธฐ๐Ÿ’ฝ ํ™œ์šฉ ๋ฐ์ดํ„ฐ์…‹ - seaborn healthexphealth_exp = sns.load_dataset('healthexp')health..
๋ˆ„์  ๋ง‰๋Œ€๊ทธ๋ž˜ํ”„ ๊ทธ๋ฆฌ๊ธฐ๐Ÿ’ฝ ํ™œ์šฉ ๋ฐ์ดํ„ฐ์…‹ - seaborn  Tipstips = sns.load_dataset('tips')tips2 = tips.groupby(['time','sex'])['tip'].mean().unstack(1)๐Ÿ“Š ๋ˆ„์  ๋ง‰๋Œ€๊ทธ๋ž˜ํ”„ ๊ทธ๋ฆฌ๊ธฐ#stacked=True ๋กœ ์„ค์ •ํ•˜๋ฉด ๋ˆ„์ ๊ทธ๋ž˜ํ”„๋ฅผ ๊ทธ๋ฆด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. stacked_plot= tips2.plot(kind='bar', stacked=True, color = ['#D4F0F0','#FEE1E8'])plt.title("Average tips by time")plt.xlabel("time")plt.xticks(rotation = 0)plt.ylabel("gender")plt.legend(loc='upper left')`kind = '..
240531 Today I Learn์ด์ƒ์น˜, ๊ฒฐ์ธก์น˜๋ž€?๐Ÿ’ก ๊ฒฐ์ธก์น˜๋ฐ์ดํ„ฐ ์ˆ˜์ง‘ ๊ณผ์ •์—์„œ ์ธก์ •๋˜์ง€ ์•Š๊ฑฐ๋‚˜ ๋ˆ„๋ฝ๋œ ๋ฐ์ดํ„ฐ๐Ÿ’ก ์ด์ƒ์น˜์ „์ฒด ๋ฐ์ดํ„ฐ ๋ฒ”์œ„์—์„œ ๋ฒ—์–ด๋‚œ ์•„์ฃผ ์ž‘์€ ๊ฐ’์ด๋‚˜ ํฐ ๊ฐ’ ํ™œ์šฉ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋”๋ณด๊ธฐimport pandas as pd import numpy as npimport timefrom PIL import Imageimport warnings# ์˜ค๋ฅ˜ ๊ฒฝ๊ณ  ๋ฌด์‹œํ•˜๊ธฐwarnings.filterwarnings(action='ignore')๊ฒฐ์ธก์น˜ ์ฒ˜๋ฆฌํ•˜๊ธฐ1. ๊ฒฐ์ธก์น˜ ์ œ๊ฑฐํ•˜๊ธฐ๊ฒฐ์ธก์น˜๊ฐ€ ์žˆ๋Š” ์—ด ์ œ๊ฑฐํ•˜๊ธฐ# ์ปฌ๋Ÿผ๋ช…์ด 'Unnamed:4'์ธ ์—ด ์ œ๊ฑฐํ•˜๊ธฐdf3 = df3.drop('Unnamed: 4', axis=1)# ์ปฌ๋Ÿผ์ด ์ œ๊ฑฐ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐdf3.isnull().sum()## user id ..
240527 Today I Learnํ•œ๊ธ€ ๊นจ์งํ˜„์ƒ ํ•ด๊ฒฐํ•˜๊ธฐsns.lineplot(data=flights, x = 'year', y = 'passengers')plt.title('์—ฐ๋„๋ณ„ ์Šน๊ฐ์ˆ˜')plt.title์„ ์•ˆ์— ํ•œ๊ธ€๋กœ ๋œ ํ…์ŠคํŠธ๋ฅผ ๋„ฃ์œผ๋ฉด ์œ„์™€ ๊ฐ™์ด ํ•œ๊ธ€ ๊นจ์ง ํ˜„์ƒ์ด ๋ฐœ์ƒํ•œ๋‹ค. ์ด ๋ฌธ์ œ๋Š” ๊ธฐ๋ณธ์œผ๋กœ ์‚ฌ์šฉ์ค‘์ธ ์‹œ์Šคํ…œ ๊ธ€๊ผด์ด ํ•œ๊ธ€์„ ์ง€์›ํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ๋ฐœ์ƒํ•œ๋‹ค. ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ํ•œ๊ธ€ ํฐํŠธ๋ฅผ ๋ณ„๋„๋กœ ์ง€์ •ํ•ด์ค˜์•ผํ•œ๋‹ค.์ ์šฉ ๊ฐ€๋Šฅํ•œ ํ•œ๊ธ€ ํฐํŠธ ์ฐพ๊ธฐ ๋ฐ ์ ์šฉํ•˜๊ธฐ๋งฅ์—์„œ๋Š” `/Users/user_name/Library/Fonts` ํด๋”์— ํฐํŠธ ํŒŒ์ผ์ด ์ €์žฅ๋˜์–ด์žˆ๋‹ค. ์•„๋‹ˆ๋ฉด '์„œ์ฒด๊ด€๋ฆฌ์ž'์—๋“ค์–ด๊ฐ€์„œ ๋งˆ์Œ์— ๋“œ๋Š” ํ•œ๊ธ€ ํฐํŠธ๋ฅผ ์„ ํƒํ•œ ๋’ค 'Finder์—์„œ ๋ณด๊ธฐ'๋ฅผ ์„ ํƒํ•ด๋„๋œ๋‹ค. ๋ณดํ†ต ttf ํŒŒ์ผ์„ ์ง€์›ํ•œ๋‹ค๊ณ  ํ•˜๋Š”๋ฐ, ..
240516 Today I Learn seaborn์œผ๋กœ ํšŒ๊ท€ ๊ทธ๋ž˜ํ”„ ๊ทธ๋ฆฌ๊ธฐ [๋ฐ์ดํ„ฐ ์‹œ๊ฐํ™”] ํŒŒ์ด์ฌ์œผ๋กœ ๊ทธ๋ž˜ํ”„ ๊ทธ๋ฆฌ๊ธฐ : seaborn (2) ํšŒ๊ท€ ๊ทธ๋ž˜ํ”„, ํžˆํŠธ๋งต ๊ทธ๋ฆฌ๊ธฐ240516 Today I LearnRegression Plotregplot๐Ÿ’กregplotsns.regplot(data=๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„, x = "x์ถ•์— ๋“ค์–ด๊ฐˆ ๋ฐ์ดํ„ฐ", y = "y์ถ•์— ๋“ค์–ด๊ฐˆ ๋ฐ์ดํ„ฐ")scatterplot์™€ lineplot์„ ํ•ฉ์ณ๋†“์€ ๊ทธ๋ž˜ํ”„lineplot์€ scatterplot์˜ ๊ฒฝํ–ฅ์„ฑ์„ ์˜ˆ์ธกarchivenyc.tistory.comsns.lmplot(data=tips,x='total_bill',y='tip')plt.title('total_bill - tip Regression')ํšŒ๊ท€์‹ ๊ทธ๋ฆฌ๊ธฐ๐Ÿ’ก polyfitํ‰๊ท  ์ œ๊ณฑ ..
240516 Today I LearnRegression Plotregplot๐Ÿ’กregplotsns.regplot(data=๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„, x = "x์ถ•์— ๋“ค์–ด๊ฐˆ ๋ฐ์ดํ„ฐ", y = "y์ถ•์— ๋“ค์–ด๊ฐˆ ๋ฐ์ดํ„ฐ")scatterplot์™€ lineplot์„ ํ•ฉ์ณ๋†“์€ ๊ทธ๋ž˜ํ”„lineplot์€ scatterplot์˜ ๊ฒฝํ–ฅ์„ฑ์„ ์˜ˆ์ธกํ•˜๋Š” ์ชฝ์œผ๋กœ ๊ทธ์–ด์งsns.regplot(data=tips,x='total_bill',y='tip')lmplot๐Ÿ’ก lmplotsns.lmplot(data=๋ฐ์ดํ„ฐํ”„๋ ˆ์ž„, x='x์ถ•์— ๋“ค์–ด๊ฐˆ ์ปฌ๋Ÿผ', y='y์ถ•์— ๋“ค์–ด๊ฐˆ ์ปฌ๋Ÿผ')regplot๊ณผ ๋‹ค๋ฅด๊ฒŒ hue๋ฅผ ์‚ฌ์šฉํ•ด categorical ๋ณ€์ˆ˜๋ฅผ ์ง€์ •ํ•ด ์นดํ…Œ๊ณ ๋ฆฌ๋ณ„๋กœ ๊ฐ๊ฐ์˜ ๋ฐ์ดํ„ฐ ๋ถ„ํฌ์™€ ์„ ํ˜• ๊ด€๊ณ„๋ฅผ ํ‘œ์‹œํ•  ์ˆ˜ ์žˆ๋‹ค.lmplot์„ ์‚ฌ์šฉํ•ด ๊ธฐ๋ณธ ๊ทธ๋ž˜ํ”„ ๊ทธ๋ฆฌ๊ธฐ..
ny:D
'๐Ÿ“’ Today I Learn/๐Ÿ Python' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (4 Page)