728x90
수치형 변수들을 잘 익혀두면 나중에 좋은 EDA를 할 수 있지않을까?란 생각에 코드를 써본당😉
In [3]:
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
#티스토리 업로드 원활하게:-)
🍒모두를 위한 데이터사이언스 클론코딩하기-3🍒¶
Pandas 공부하기
라이브러리 로드¶
In [4]:
import pandas as pd
import seaborn as sns
In [5]:
pd.__version__
Out[5]:
'1.3.4'
In [6]:
sns.__version__
Out[6]:
'0.11.2'
데이터셋 불러오기¶
In [7]:
#자동차 연비 데이터셋 불러오기
df = sns.load_dataset("mpg")
In [8]:
df
Out[8]:
mpg | cylinders | displacement | horsepower | weight | acceleration | model_year | origin | name | |
---|---|---|---|---|---|---|---|---|---|
0 | 18.0 | 8 | 307.0 | 130.0 | 3504 | 12.0 | 70 | usa | chevrolet chevelle malibu |
1 | 15.0 | 8 | 350.0 | 165.0 | 3693 | 11.5 | 70 | usa | buick skylark 320 |
2 | 18.0 | 8 | 318.0 | 150.0 | 3436 | 11.0 | 70 | usa | plymouth satellite |
3 | 16.0 | 8 | 304.0 | 150.0 | 3433 | 12.0 | 70 | usa | amc rebel sst |
4 | 17.0 | 8 | 302.0 | 140.0 | 3449 | 10.5 | 70 | usa | ford torino |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
393 | 27.0 | 4 | 140.0 | 86.0 | 2790 | 15.6 | 82 | usa | ford mustang gl |
394 | 44.0 | 4 | 97.0 | 52.0 | 2130 | 24.6 | 82 | europe | vw pickup |
395 | 32.0 | 4 | 135.0 | 84.0 | 2295 | 11.6 | 82 | usa | dodge rampage |
396 | 28.0 | 4 | 120.0 | 79.0 | 2625 | 18.6 | 82 | usa | ford ranger |
397 | 31.0 | 4 | 119.0 | 82.0 | 2720 | 19.4 | 82 | usa | chevy s-10 |
398 rows × 9 columns
In [7]:
# 398 행 9열
df.shape
Out[7]:
(398, 9)
복습하기¶
In [9]:
df.index
Out[9]:
RangeIndex(start=0, stop=398, step=1)
In [10]:
df.columns
Out[10]:
Index(['mpg', 'cylinders', 'displacement', 'horsepower', 'weight',
'acceleration', 'model_year', 'origin', 'name'],
dtype='object')
In [11]:
df.values
Out[11]:
array([[18.0, 8, 307.0, ..., 70, 'usa', 'chevrolet chevelle malibu'],
[15.0, 8, 350.0, ..., 70, 'usa', 'buick skylark 320'],
[18.0, 8, 318.0, ..., 70, 'usa', 'plymouth satellite'],
...,
[32.0, 4, 135.0, ..., 82, 'usa', 'dodge rampage'],
[28.0, 4, 120.0, ..., 82, 'usa', 'ford ranger'],
[31.0, 4, 119.0, ..., 82, 'usa', 'chevy s-10']], dtype=object)
In [12]:
df.dtypes
Out[12]:
mpg float64
cylinders int64
displacement float64
horsepower float64
weight int64
acceleration float64
model_year int64
origin object
name object
dtype: object
In [13]:
# 위 5개 = 기본값
df.head()
Out[13]:
mpg | cylinders | displacement | horsepower | weight | acceleration | model_year | origin | name | |
---|---|---|---|---|---|---|---|---|---|
0 | 18.0 | 8 | 307.0 | 130.0 | 3504 | 12.0 | 70 | usa | chevrolet chevelle malibu |
1 | 15.0 | 8 | 350.0 | 165.0 | 3693 | 11.5 | 70 | usa | buick skylark 320 |
2 | 18.0 | 8 | 318.0 | 150.0 | 3436 | 11.0 | 70 | usa | plymouth satellite |
3 | 16.0 | 8 | 304.0 | 150.0 | 3433 | 12.0 | 70 | usa | amc rebel sst |
4 | 17.0 | 8 | 302.0 | 140.0 | 3449 | 10.5 | 70 | usa | ford torino |
In [14]:
#아래 5개 = 기본값
df.tail()
Out[14]:
mpg | cylinders | displacement | horsepower | weight | acceleration | model_year | origin | name | |
---|---|---|---|---|---|---|---|---|---|
393 | 27.0 | 4 | 140.0 | 86.0 | 2790 | 15.6 | 82 | usa | ford mustang gl |
394 | 44.0 | 4 | 97.0 | 52.0 | 2130 | 24.6 | 82 | europe | vw pickup |
395 | 32.0 | 4 | 135.0 | 84.0 | 2295 | 11.6 | 82 | usa | dodge rampage |
396 | 28.0 | 4 | 120.0 | 79.0 | 2625 | 18.6 | 82 | usa | ford ranger |
397 | 31.0 | 4 | 119.0 | 82.0 | 2720 | 19.4 | 82 | usa | chevy s-10 |
In [15]:
#랜덤으로 1개 가져오기 = 기본값
df.sample()
Out[15]:
mpg | cylinders | displacement | horsepower | weight | acceleration | model_year | origin | name | |
---|---|---|---|---|---|---|---|---|---|
129 | 31.0 | 4 | 79.0 | 67.0 | 1950 | 19.0 | 74 | japan | datsun b210 |
In [16]:
#비교
#랜덤으로 4개 가져오기 -> 실행할떄마다 같은 값
df.sample(4,random_state=42)
Out[16]:
mpg | cylinders | displacement | horsepower | weight | acceleration | model_year | origin | name | |
---|---|---|---|---|---|---|---|---|---|
198 | 33.0 | 4 | 91.0 | 53.0 | 1795 | 17.4 | 76 | japan | honda civic |
396 | 28.0 | 4 | 120.0 | 79.0 | 2625 | 18.6 | 82 | usa | ford ranger |
33 | 19.0 | 6 | 232.0 | 100.0 | 2634 | 13.0 | 71 | usa | amc gremlin |
208 | 13.0 | 8 | 318.0 | 150.0 | 3940 | 13.2 | 76 | usa | plymouth volare premier v8 |
In [17]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 398 entries, 0 to 397
Data columns (total 9 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 mpg 398 non-null float64
1 cylinders 398 non-null int64
2 displacement 398 non-null float64
3 horsepower 392 non-null float64
4 weight 398 non-null int64
5 acceleration 398 non-null float64
6 model_year 398 non-null int64
7 origin 398 non-null object
8 name 398 non-null object
dtypes: float64(4), int64(3), object(2)
memory usage: 28.1+ KB
In [19]:
#결측치수 확인하기
df.isnull().sum()
Out[19]:
mpg 0
cylinders 0
displacement 0
horsepower 6
weight 0
acceleration 0
model_year 0
origin 0
name 0
dtype: int64
In [20]:
#전체 값대비 결측치개수인 결측치 비율 확인
df.isnull().mean()
Out[20]:
mpg 0.000000
cylinders 0.000000
displacement 0.000000
horsepower 0.015075
weight 0.000000
acceleration 0.000000
model_year 0.000000
origin 0.000000
name 0.000000
dtype: float64
In [26]:
df.isnull().mean()*100
Out[26]:
mpg 0.000000
cylinders 0.000000
displacement 0.000000
horsepower 1.507538
weight 0.000000
acceleration 0.000000
model_year 0.000000
origin 0.000000
name 0.000000
dtype: float64
In [23]:
df.describe()
Out[23]:
mpg | cylinders | displacement | horsepower | weight | acceleration | model_year | |
---|---|---|---|---|---|---|---|
count | 398.000000 | 398.000000 | 398.000000 | 392.000000 | 398.000000 | 398.000000 | 398.000000 |
mean | 23.514573 | 5.454774 | 193.425879 | 104.469388 | 2970.424623 | 15.568090 | 76.010050 |
std | 7.815984 | 1.701004 | 104.269838 | 38.491160 | 846.841774 | 2.757689 | 3.697627 |
min | 9.000000 | 3.000000 | 68.000000 | 46.000000 | 1613.000000 | 8.000000 | 70.000000 |
25% | 17.500000 | 4.000000 | 104.250000 | 75.000000 | 2223.750000 | 13.825000 | 73.000000 |
50% | 23.000000 | 4.000000 | 148.500000 | 93.500000 | 2803.500000 | 15.500000 | 76.000000 |
75% | 29.000000 | 8.000000 | 262.000000 | 126.000000 | 3608.000000 | 17.175000 | 79.000000 |
max | 46.600000 | 8.000000 | 455.000000 | 230.000000 | 5140.000000 | 24.800000 | 82.000000 |
In [24]:
df.describe(include="object")
Out[24]:
origin | name | |
---|---|---|
count | 398 | 398 |
unique | 3 | 305 |
top | usa | ford pinto |
freq | 249 | 6 |
In [26]:
df["mpg"].unique()
Out[26]:
array([18. , 15. , 16. , 17. , 14. , 24. , 22. , 21. , 27. , 26. , 25. ,
10. , 11. , 9. , 28. , 19. , 12. , 13. , 23. , 30. , 31. , 35. ,
20. , 29. , 32. , 33. , 17.5, 15.5, 14.5, 22.5, 24.5, 18.5, 29.5,
26.5, 16.5, 31.5, 36. , 25.5, 33.5, 20.5, 30.5, 21.5, 43.1, 36.1,
32.8, 39.4, 19.9, 19.4, 20.2, 19.2, 25.1, 20.6, 20.8, 18.6, 18.1,
17.7, 27.5, 27.2, 30.9, 21.1, 23.2, 23.8, 23.9, 20.3, 21.6, 16.2,
19.8, 22.3, 17.6, 18.2, 16.9, 31.9, 34.1, 35.7, 27.4, 25.4, 34.2,
34.5, 31.8, 37.3, 28.4, 28.8, 26.8, 41.5, 38.1, 32.1, 37.2, 26.4,
24.3, 19.1, 34.3, 29.8, 31.3, 37. , 32.2, 46.6, 27.9, 40.8, 44.3,
43.4, 36.4, 44.6, 40.9, 33.8, 32.7, 23.7, 23.6, 32.4, 26.6, 25.8,
23.5, 39.1, 39. , 35.1, 32.3, 37.7, 34.7, 34.4, 29.9, 33.7, 32.9,
31.6, 28.1, 30.7, 24.2, 22.4, 34. , 38. , 44. ])
In [27]:
df["cylinders"].unique()
Out[27]:
array([8, 4, 6, 3, 5], dtype=int64)
In [29]:
df["mpg"].nunique()
Out[29]:
129
In [30]:
df.hist()
Out[30]:
array([[<AxesSubplot:title={'center':'mpg'}>,
<AxesSubplot:title={'center':'cylinders'}>,
<AxesSubplot:title={'center':'displacement'}>],
[<AxesSubplot:title={'center':'horsepower'}>,
<AxesSubplot:title={'center':'weight'}>,
<AxesSubplot:title={'center':'acceleration'}>],
[<AxesSubplot:title={'center':'model_year'}>, <AxesSubplot:>,
<AxesSubplot:>]], dtype=object)
In [31]:
_ = df.hist()
In [32]:
_=df.hist(figsize=(10,10), bins=1)
In [33]:
_=df.hist(figsize=(8,8),bins=5)
In [35]:
_=df.hist(figsize=(8,8),bins=50)
비대칭도(왜도)¶
In [41]:
df.skew()
C:\Users\light\AppData\Local\Temp/ipykernel_5976/1665899112.py:1: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.
df.skew()
Out[41]:
mpg 0.457066
cylinders 0.526922
displacement 0.719645
horsepower 1.087326
weight 0.531063
acceleration 0.278777
model_year 0.011535
dtype: float64
첨도¶
In [38]:
df.kurt()
C:\Users\light\AppData\Local\Temp/ipykernel_5976/1257127604.py:1: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError. Select only valid columns before calling the reduction.
df.kurt()
Out[38]:
mpg -0.510781
cylinders -1.376662
displacement -0.746597
horsepower 0.696947
weight -0.785529
acceleration 0.419497
model_year -1.181232
dtype: float64
1개의 수치 변수¶
In [42]:
sns.displot(data=df, x="mpg")
Out[42]:
<seaborn.axisgrid.FacetGrid at 0x1f145b415b0>
In [44]:
sns.displot(data=df, x="mpg", kde=True)
Out[44]:
<seaborn.axisgrid.FacetGrid at 0x1f14426a940>
In [45]:
sns.displot(data=df, x="mpg", kde=True, rug=True) #빈도수
Out[45]:
<seaborn.axisgrid.FacetGrid at 0x1f1470709d0>
In [47]:
sns.kdeplot(data=df["mpg"])
Out[47]:
<AxesSubplot:xlabel='mpg', ylabel='Density'>
In [49]:
#동일식
sns.kdeplot(data=df, x="mpg")
Out[49]:
<AxesSubplot:xlabel='mpg', ylabel='Density'>
In [50]:
sns.rugplot(data=df["mpg"])
Out[50]:
<AxesSubplot:xlabel='mpg'>
In [55]:
sns.kdeplot(data=df["mpg"], shade=True, cut=20) #cut으로 범위 바꾸기
Out[55]:
<AxesSubplot:xlabel='mpg', ylabel='Density'>
In [53]:
sns.kdeplot(data=df["mpg"], shade=True)
Out[53]:
<AxesSubplot:xlabel='mpg', ylabel='Density'>
In [58]:
df["mpg"].agg(["skew","kurt"])
# 왜도 왼쪽 오른쪽
# 첨도 뾰쪽한 정도
Out[58]:
skew 0.457066
kurt -0.510781
Name: mpg, dtype: float64
In [59]:
sns.boxplot(data=df['mpg'])
Out[59]:
<AxesSubplot:>
In [64]:
sns.boxplot(data=df, x="mpg")
Out[64]:
<AxesSubplot:xlabel='mpg'>
In [67]:
df["mpg"].describe()
Out[67]:
count 398.000000
mean 23.514573
std 7.815984
min 9.000000
25% 17.500000
50% 23.000000
75% 29.000000
max 46.600000
Name: mpg, dtype: float64
In [69]:
sns.violinplot(data=df, x="mpg")
Out[69]:
<AxesSubplot:xlabel='mpg'>
In [71]:
sns.boxplot(data=df)
Out[71]:
<AxesSubplot:>
In [72]:
sns.violinplot(data=df)
Out[72]:
<AxesSubplot:>
2개이상 수치 변수¶
In [73]:
sns.scatterplot(data=df)
Out[73]:
<AxesSubplot:>
In [74]:
sns.scatterplot(data=df, x="weight", y="mpg")
Out[74]:
<AxesSubplot:xlabel='weight', ylabel='mpg'>
In [75]:
sns.scatterplot(data=df, x="weight", y="mpg", hue="origin")
Out[75]:
<AxesSubplot:xlabel='weight', ylabel='mpg'>
In [77]:
sns.regplot(data=df, x="weight", y="mpg") #회귀시각화
Out[77]:
<AxesSubplot:xlabel='weight', ylabel='mpg'>
In [78]:
sns.regplot(data=df, x="weight", y="mpg", scatter=False)
Out[78]:
<AxesSubplot:xlabel='weight', ylabel='mpg'>
In [79]:
sns.residplot(data=df, x="weight", y="mpg")
Out[79]:
<AxesSubplot:xlabel='weight', ylabel='mpg'>
In [80]:
sns.residplot(data=df, x="weight", y="mpg")
Out[80]:
<AxesSubplot:xlabel='weight', ylabel='mpg'>
In [84]:
sns.lmplot(data=df, x="weight", y="mpg")
# 동일식: sns.regplot(data=df, x="weight", y="mpg")
Out[84]:
<seaborn.axisgrid.FacetGrid at 0x1f146dfb7c0>
In [85]:
sns.lmplot(data=df, x="weight", y="mpg", hue="origin")
Out[85]:
<seaborn.axisgrid.FacetGrid at 0x1f142057a30>
In [86]:
sns.lmplot(data=df, x="weight", y="mpg", hue="origin", col="origin")
Out[86]:
<seaborn.axisgrid.FacetGrid at 0x1f1441494c0>
In [87]:
sns.lmplot(data=df, x="weight", y="mpg", hue="origin", col="origin", truncate=False)
Out[87]:
<seaborn.axisgrid.FacetGrid at 0x1f14741d8b0>
In [88]:
sns.jointplot(data=df, x="weight", y="mpg")
Out[88]:
<seaborn.axisgrid.JointGrid at 0x1f142e582b0>
In [89]:
sns.jointplot(data=df, x="weight", y="mpg", kind="kde")
Out[89]:
<seaborn.axisgrid.JointGrid at 0x1f1473d3a30>
In [91]:
sns.jointplot(data=df, x="weight", y="mpg", kind="reg")
Out[91]:
<seaborn.axisgrid.JointGrid at 0x1f1475aec10>
In [92]:
sns.jointplot(data=df, x="weight", y="mpg", kind="hex")
Out[92]:
<seaborn.axisgrid.JointGrid at 0x1f149618e80>
In [93]:
df_sample=df.sample(100)
df_sample
Out[93]:
mpg | cylinders | displacement | horsepower | weight | acceleration | model_year | origin | name | |
---|---|---|---|---|---|---|---|---|---|
85 | 13.0 | 8 | 350.0 | 175.0 | 4100 | 13.0 | 73 | usa | buick century 350 |
172 | 25.0 | 4 | 90.0 | 71.0 | 2223 | 16.5 | 75 | europe | volkswagen dasher |
0 | 18.0 | 8 | 307.0 | 130.0 | 3504 | 12.0 | 70 | usa | chevrolet chevelle malibu |
209 | 19.0 | 4 | 120.0 | 88.0 | 3270 | 21.9 | 76 | europe | peugeot 504 |
248 | 36.1 | 4 | 91.0 | 60.0 | 1800 | 16.4 | 78 | japan | honda civic cvcc |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
241 | 22.0 | 6 | 146.0 | 97.0 | 2815 | 14.5 | 77 | japan | datsun 810 |
194 | 22.5 | 6 | 232.0 | 90.0 | 3085 | 17.6 | 76 | usa | amc hornet |
78 | 21.0 | 4 | 120.0 | 87.0 | 2979 | 19.5 | 72 | europe | peugeot 504 (sw) |
121 | 15.0 | 8 | 318.0 | 150.0 | 3399 | 11.0 | 73 | usa | dodge dart custom |
56 | 26.0 | 4 | 91.0 | 70.0 | 1955 | 20.5 | 71 | usa | plymouth cricket |
100 rows × 9 columns
In [94]:
sns.pairplot(data=df_sample, hue="origin")
Out[94]:
<seaborn.axisgrid.PairGrid at 0x1f1498be520>
In [95]:
sns.scatterplot(data=df,x="model_year", y="mpg" )
Out[95]:
<AxesSubplot:xlabel='model_year', ylabel='mpg'>
In [96]:
sns.lineplot(data=df, x="model_year", y="mpg")
Out[96]:
<AxesSubplot:xlabel='model_year', ylabel='mpg'>
In [98]:
sns.lineplot(data=df, x="model_year", y="mpg", ci=None)
#ci는 신뢰구간을 의미
Out[98]:
<AxesSubplot:xlabel='model_year', ylabel='mpg'>
In [101]:
sns.relplot(data=df, x="model_year", y="mpg", hue="origin", col="origin" )
Out[101]:
<seaborn.axisgrid.FacetGrid at 0x1f14c546cd0>
In [102]:
sns.relplot(data=df)
Out[102]:
<seaborn.axisgrid.FacetGrid at 0x1f14c6ee430>
In [103]:
sns.relplot(data=df, x="model_year", y="mpg", col="origin", hue="origin", kind="line", ci=None)
Out[103]:
<seaborn.axisgrid.FacetGrid at 0x1f14c9bb3d0>
In [104]:
corr=df.corr()
corr
Out[104]:
mpg | cylinders | displacement | horsepower | weight | acceleration | model_year | |
---|---|---|---|---|---|---|---|
mpg | 1.000000 | -0.775396 | -0.804203 | -0.778427 | -0.831741 | 0.420289 | 0.579267 |
cylinders | -0.775396 | 1.000000 | 0.950721 | 0.842983 | 0.896017 | -0.505419 | -0.348746 |
displacement | -0.804203 | 0.950721 | 1.000000 | 0.897257 | 0.932824 | -0.543684 | -0.370164 |
horsepower | -0.778427 | 0.842983 | 0.897257 | 1.000000 | 0.864538 | -0.689196 | -0.416361 |
weight | -0.831741 | 0.896017 | 0.932824 | 0.864538 | 1.000000 | -0.417457 | -0.306564 |
acceleration | 0.420289 | -0.505419 | -0.543684 | -0.689196 | -0.417457 | 1.000000 | 0.288137 |
model_year | 0.579267 | -0.348746 | -0.370164 | -0.416361 | -0.306564 | 0.288137 | 1.000000 |
In [111]:
import numpy as np
import matplotlib.pyplot as plt
In [107]:
np.ones_like(corr)
Out[107]:
array([[1., 1., 1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1., 1., 1.],
[1., 1., 1., 1., 1., 1., 1.]])
In [108]:
mask = np.triu(np.ones_like(corr)) #상 삼각행렬만들기
mask
Out[108]:
array([[1., 1., 1., 1., 1., 1., 1.],
[0., 1., 1., 1., 1., 1., 1.],
[0., 0., 1., 1., 1., 1., 1.],
[0., 0., 0., 1., 1., 1., 1.],
[0., 0., 0., 0., 1., 1., 1.],
[0., 0., 0., 0., 0., 1., 1.],
[0., 0., 0., 0., 0., 0., 1.]])
In [116]:
print(plt.colormaps())
['Accent', 'Accent_r', 'Blues', 'Blues_r', 'BrBG', 'BrBG_r', 'BuGn', 'BuGn_r', 'BuPu', 'BuPu_r', 'CMRmap', 'CMRmap_r', 'Dark2', 'Dark2_r', 'GnBu', 'GnBu_r', 'Greens', 'Greens_r', 'Greys', 'Greys_r', 'OrRd', 'OrRd_r', 'Oranges', 'Oranges_r', 'PRGn', 'PRGn_r', 'Paired', 'Paired_r', 'Pastel1', 'Pastel1_r', 'Pastel2', 'Pastel2_r', 'PiYG', 'PiYG_r', 'PuBu', 'PuBuGn', 'PuBuGn_r', 'PuBu_r', 'PuOr', 'PuOr_r', 'PuRd', 'PuRd_r', 'Purples', 'Purples_r', 'RdBu', 'RdBu_r', 'RdGy', 'RdGy_r', 'RdPu', 'RdPu_r', 'RdYlBu', 'RdYlBu_r', 'RdYlGn', 'RdYlGn_r', 'Reds', 'Reds_r', 'Set1', 'Set1_r', 'Set2', 'Set2_r', 'Set3', 'Set3_r', 'Spectral', 'Spectral_r', 'Wistia', 'Wistia_r', 'YlGn', 'YlGnBu', 'YlGnBu_r', 'YlGn_r', 'YlOrBr', 'YlOrBr_r', 'YlOrRd', 'YlOrRd_r', 'afmhot', 'afmhot_r', 'autumn', 'autumn_r', 'binary', 'binary_r', 'bone', 'bone_r', 'brg', 'brg_r', 'bwr', 'bwr_r', 'cividis', 'cividis_r', 'cool', 'cool_r', 'coolwarm', 'coolwarm_r', 'copper', 'copper_r', 'crest', 'crest_r', 'cubehelix', 'cubehelix_r', 'flag', 'flag_r', 'flare', 'flare_r', 'gist_earth', 'gist_earth_r', 'gist_gray', 'gist_gray_r', 'gist_heat', 'gist_heat_r', 'gist_ncar', 'gist_ncar_r', 'gist_rainbow', 'gist_rainbow_r', 'gist_stern', 'gist_stern_r', 'gist_yarg', 'gist_yarg_r', 'gnuplot', 'gnuplot2', 'gnuplot2_r', 'gnuplot_r', 'gray', 'gray_r', 'hot', 'hot_r', 'hsv', 'hsv_r', 'icefire', 'icefire_r', 'inferno', 'inferno_r', 'jet', 'jet_r', 'magma', 'magma_r', 'mako', 'mako_r', 'nipy_spectral', 'nipy_spectral_r', 'ocean', 'ocean_r', 'pink', 'pink_r', 'plasma', 'plasma_r', 'prism', 'prism_r', 'rainbow', 'rainbow_r', 'rocket', 'rocket_r', 'seismic', 'seismic_r', 'spring', 'spring_r', 'summer', 'summer_r', 'tab10', 'tab10_r', 'tab20', 'tab20_r', 'tab20b', 'tab20b_r', 'tab20c', 'tab20c_r', 'terrain', 'terrain_r', 'turbo', 'turbo_r', 'twilight', 'twilight_r', 'twilight_shifted', 'twilight_shifted_r', 'viridis', 'viridis_r', 'vlag', 'vlag_r', 'winter', 'winter_r']
In [114]:
sns.heatmap(corr, annot=True, cmap="coolwarm", vmax=1, vmin=-1)
Out[114]:
<AxesSubplot:>
In [120]:
sns.heatmap(corr, annot=True, cmap="bone", vmax=1, vmin=-1)
Out[120]:
<AxesSubplot:>
In [121]:
sns.heatmap(corr, annot=True, cmap="coolwarm", vmax=1, vmin=-1,mask=mask)
Out[121]:
<AxesSubplot:>
In [ ]:
728x90
'😁 빅데이터 문제 풀기 & Study > - 클론코딩하기' 카테고리의 다른 글
[pandas] 🍒모두를 위한 데이터사이언스 클론코딩하기-2.기술통계 (0) | 2022.01.27 |
---|---|
[pandas] 🍒모두를 위한 데이터사이언스 클론코딩하기-1 (0) | 2022.01.25 |