ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • #10
    Python/Jupyter notebook 2023. 1. 16. 21:38
    import seaborn as sns
    import matplotlib.pyplot as plt
    
    In [2]:
    sns.set_theme(style="whitegrid") # seaborn의 테마 중 하나인 whitegrid로 나옴
    
    In [ ]:
    # sns.set() # seaborn의 기본 테마인 darkgrid로 나옴
    
    In [3]:
    penguins = sns.load_dataset("penguins")
    
    In [4]:
    penguins
    
    Out[4]:
    speciesislandbill_length_mmbill_depth_mmflipper_length_mmbody_mass_gsex01234...339340341342343
    Adelie Torgersen 39.1 18.7 181.0 3750.0 Male
    Adelie Torgersen 39.5 17.4 186.0 3800.0 Female
    Adelie Torgersen 40.3 18.0 195.0 3250.0 Female
    Adelie Torgersen NaN NaN NaN NaN NaN
    Adelie Torgersen 36.7 19.3 193.0 3450.0 Female
    ... ... ... ... ... ... ...
    Gentoo Biscoe NaN NaN NaN NaN NaN
    Gentoo Biscoe 46.8 14.3 215.0 4850.0 Female
    Gentoo Biscoe 50.4 15.7 222.0 5750.0 Male
    Gentoo Biscoe 45.2 14.8 212.0 5200.0 Female
    Gentoo Biscoe 49.9 16.1 213.0 5400.0 Male

    344 rows × 7 columns

    In [11]:
    # Draw a nested barplot by species and sex
    g = sns.catplot(
        data=penguins, kind="bar",
        x="species", y="body_mass_g", hue="sex",
        palette="dark", alpha=.6, height=6
    )
    
    g.despine(left=True)
    g.set_axis_labels("", "Body mass (g)")
    g.legend.set_title("")
    
    plt.show()
    
    In [ ]:
     
    
    In [ ]:
     
    
    In [12]:
    import seaborn as sns
    import matplotlib.pyplot as plt
    
    In [14]:
    sns.set_theme(style="darkgrid")
    
    In [17]:
    mpg = sns.load_dataset("mpg")
    
    In [18]:
    mpg
    
    Out[18]:
    mpgcylindersdisplacementhorsepowerweightaccelerationmodel_yearoriginname01234...393394395396397
    18.0 8 307.0 130.0 3504 12.0 70 usa chevrolet chevelle malibu
    15.0 8 350.0 165.0 3693 11.5 70 usa buick skylark 320
    18.0 8 318.0 150.0 3436 11.0 70 usa plymouth satellite
    16.0 8 304.0 150.0 3433 12.0 70 usa amc rebel sst
    17.0 8 302.0 140.0 3449 10.5 70 usa ford torino
    ... ... ... ... ... ... ... ... ...
    27.0 4 140.0 86.0 2790 15.6 82 usa ford mustang gl
    44.0 4 97.0 52.0 2130 24.6 82 europe vw pickup
    32.0 4 135.0 84.0 2295 11.6 82 usa dodge rampage
    28.0 4 120.0 79.0 2625 18.6 82 usa ford ranger
    31.0 4 119.0 82.0 2720 19.4 82 usa chevy s-10

    398 rows × 9 columns

    In [20]:
    mpg['origin'].unique()
    
    Out[20]:
    array(['usa', 'japan', 'europe'], dtype=object)
    In [21]:
    # 국가별 차량의 마력을 시각화
    # origin: 국가, horsepower: 마력
    
    In [23]:
    sns.barplot(data=mpg, x='origin', y='horsepower')
    plt.show()
    
    In [24]:
    sns.barplot(data=mpg, x='origin', y='horsepower')
    
    Out[24]:
    <AxesSubplot:xlabel='origin', ylabel='horsepower'>
    In [25]:
    # 매직코드 - matplotlib
    # 출력을 하지 않더라도 그래프가 보이게 해줌
    %matplotlib inline
    
    In [26]:
    sns.barplot(data=mpg, x='origin', y='horsepower')
    
    Out[26]:
    <AxesSubplot:xlabel='origin', ylabel='horsepower'>
    In [27]:
    sns.barplot(data=mpg, x='origin', y='horsepower')
    plt.title('horsepower - origin')
    
    Out[27]:
    Text(0.5, 1.0, 'horsepower - origin')
    In [29]:
    # 한국어가 깨진다면 글꼴을 맑은 고딕으로 변경하자
    plt.rcParams['font.family'] = 'Malgun Gothic'
    
    In [38]:
    sns.barplot(data=mpg, x='origin', y='horsepower')
    plt.title('국가별 자동차의 마력 현황') # 제목
    plt.xlabel('국가') # x축 이름
    plt.ylabel('마력') # y축 이름
    # plt.legend() # 범주 구분
    plt.savefig('F:/신입강의/data/fig.png', dpi=300) # 파일 저장. dpi: 해상도
    
    In [39]:
    sns.barplot(data=mpg, y='origin', x='horsepower')
    plt.title('국가별 자동차의 마력 현황') # 제목
    
    Out[39]:
    Text(0.5, 1.0, '국가별 자동차의 마력 현황')
    In [ ]:
    sns.set_theme(style="ticks", palette="pastel")
    
    In [40]:
    # Load the example tips dataset
    tips = sns.load_dataset("tips")
    
    In [41]:
    tips
    
    Out[41]:
    total_billtipsexsmokerdaytimesize01234...239240241242243
    16.99 1.01 Female No Sun Dinner 2
    10.34 1.66 Male No Sun Dinner 3
    21.01 3.50 Male No Sun Dinner 3
    23.68 3.31 Male No Sun Dinner 2
    24.59 3.61 Female No Sun Dinner 4
    ... ... ... ... ... ... ...
    29.03 5.92 Male No Sat Dinner 3
    27.18 2.00 Female Yes Sat Dinner 2
    22.67 2.00 Male Yes Sat Dinner 2
    17.82 1.75 Male No Sat Dinner 2
    18.78 3.00 Female No Thur Dinner 2

    244 rows × 7 columns

    In [42]:
    # Draw a nested boxplot to show bills by day and time
    sns.boxplot(x="day", y="total_bill",
                hue="smoker", palette=["m", "g"],
                data=tips)
    sns.despine(offset=10, trim=True)
    
    In [51]:
    exercise = sns.load_dataset('exercise')
    
    In [45]:
    exercise
    
    Out[45]:
    Unnamed: 0iddietpulsetimekind01234...8586878889
    0 1 low fat 85 1 min rest
    1 1 low fat 85 15 min rest
    2 1 low fat 88 30 min rest
    3 2 low fat 90 1 min rest
    4 2 low fat 92 15 min rest
    ... ... ... ... ... ...
    85 29 no fat 135 15 min running
    86 29 no fat 130 30 min running
    87 30 no fat 99 1 min running
    88 30 no fat 111 15 min running
    89 30 no fat 150 30 min running

    90 rows × 6 columns

    In [46]:
    sns.boxplot(data=exercise, x='diet',y='pulse')
    
    Out[46]:
    <AxesSubplot:xlabel='diet', ylabel='pulse'>

    실습

    • 위 그래프를 다음과 같이 수정해보자
    1. x축의 이름을 '식이요법'으로 하고, no fat = '무지방 식단', low fat = '저지방 식단'으로 바꿔보자
    2. y축의 이름을 없앤다
    3. 그래프의 제목을 '식이요법에 따른 심박수 변화' 로 하는데, 심박수 변화는 줄바꿈을 한 뒤 적는다
    4. 해당 그래프를 다운로드 폴더에 저장한다 (이름: fat.jpg, 해상도 = 80dpi)
    In [78]:
    # exercise['diet'] = exercise['diet'].apply(lambda x: '무지방 식단' if x == 'no fat' else '저지방 식단')
    
    plt.figure(figsize=(2,3))
    
    sns.boxplot(data=exercise, x='diet',y='pulse')
    plt.xlabel('식이요법')
    plt.ylabel('')
    plt.title('식이요법에 따른\n심박수 변화')
    plt.xticks([0,1], labels=['A','B'])
    # plt.yscale('log')
    plt.ylim(100,160)
    # plt.savefig('C:/Users/user/Downloads/fat.jpg', dpi=80)
    
    Out[78]:
    (100.0, 160.0)

    실습

    • diet 분류에 따른 pulse 값의 차이가 있는지 알아보자
    • 아래 코드를 참고해서 boxplot과 t-test 결과를 함께 출력한다
    In [81]:
    sns.boxplot(data=exercise, x='diet',y='pulse')
    plt.text(0.75,130,'여기에 글자를 쓸 수 있습니다')
    
    Out[81]:
    Text(0.75, 130, '여기에 글자를 쓸 수 있습니다')
    In [83]:
    exercise['diet'].unique()
    
    Out[83]:
    ['저지방 식단', '무지방 식단']
    Categories (2, object): ['무지방 식단', '저지방 식단']
    In [84]:
    m = exercise['diet'] == '저지방 식단'
    
    In [86]:
    exercise[m].shape, exercise[-m].shape
    
    Out[86]:
    ((45, 6), (45, 6))
    In [87]:
    from scipy import stats
    
    In [91]:
    a = exercise[m]['pulse']
    b = exercise[-m]['pulse']
    
    In [92]:
    stats.ttest_ind(a, b)
    
    Out[92]:
    Ttest_indResult(statistic=-2.457504273642696, pvalue=0.015951606961272263)
    In [94]:
    p = stats.ttest_ind(a, b)[1]
    
    In [106]:
    plt.figure(figsize=(3,3))
    sns.boxplot(data=exercise, x='diet',y='pulse')
    plt.text(0.7,145,'p = %.4f' %p)
    
    Out[106]:
    Text(0.7, 145, 'p = 0.0160')
    In [107]:
    import pandas as pd
    
    In [120]:
    df = pd.DataFrame({'저지방':a.values, '무지방':b.values})
    
    In [122]:
    df.head()
    
    Out[122]:
    저지방무지방01234
    85 83
    85 83
    88 84
    90 87
    92 88
    In [123]:
    pd.melt(df)
    
    Out[123]:
    variablevalue01234...8586878889
    저지방 85
    저지방 85
    저지방 88
    저지방 90
    저지방 92
    ... ...
    무지방 135
    무지방 130
    무지방 99
    무지방 111
    무지방 150

    90 rows × 2 columns

    In [124]:
    # Load the example diamonds dataset
    diamonds = sns.load_dataset("diamonds")
    
    In [125]:
    diamonds
    
    Out[125]:
    caratcutcolorclaritydepthtablepricexyz01234...5393553936539375393853939
    0.23 Ideal E SI2 61.5 55.0 326 3.95 3.98 2.43
    0.21 Premium E SI1 59.8 61.0 326 3.89 3.84 2.31
    0.23 Good E VS1 56.9 65.0 327 4.05 4.07 2.31
    0.29 Premium I VS2 62.4 58.0 334 4.20 4.23 2.63
    0.31 Good J SI2 63.3 58.0 335 4.34 4.35 2.75
    ... ... ... ... ... ... ... ... ... ...
    0.72 Ideal D SI1 60.8 57.0 2757 5.75 5.76 3.50
    0.72 Good D SI1 63.1 55.0 2757 5.69 5.75 3.61
    0.70 Very Good D SI1 62.8 60.0 2757 5.66 5.68 3.56
    0.86 Premium H SI2 61.0 58.0 2757 6.15 6.12 3.74
    0.75 Ideal D SI2 62.2 55.0 2757 5.83 5.87 3.64

    53940 rows × 10 columns

    In [131]:
    f, ax = plt.subplots(figsize=(5.5, 5.5))
    sns.despine(f, left=True, bottom=True)
    clarity_ranking = ["I1", "SI2", "SI1", "VS2", "VS1", "VVS2", "VVS1", "IF"]
    
    sns.scatterplot(x="carat", y="price",
                    hue="clarity", size="depth",
                    palette="ch:r=-.2,d=.3_r",
                    hue_order=clarity_ranking,
                    sizes=(1, 8), linewidth=0,
                    data=diamonds, ax=ax)
    
    Out[131]:
    <AxesSubplot:xlabel='carat', ylabel='price'>
    In [134]:
    planets = sns.load_dataset('planets')
    
    In [135]:
    planets
    
    Out[135]:
    methodnumberorbital_periodmassdistanceyear01234...10301031103210331034
    Radial Velocity 1 269.300000 7.10 77.40 2006
    Radial Velocity 1 874.774000 2.21 56.95 2008
    Radial Velocity 1 763.000000 2.60 19.84 2011
    Radial Velocity 1 326.030000 19.40 110.62 2007
    Radial Velocity 1 516.220000 10.50 119.47 2009
    ... ... ... ... ... ...
    Transit 1 3.941507 NaN 172.00 2006
    Transit 1 2.615864 NaN 148.00 2007
    Transit 1 3.191524 NaN 174.00 2007
    Transit 1 4.125083 NaN 293.00 2008
    Transit 1 4.187757 NaN 260.00 2008

    1035 rows × 6 columns

    In [151]:
    sns.regplot(data=planets, x='distance', y='orbital_period')
    plt.yscale('log')
    plt.xscale('log')
    
    Font 'default' does not have a glyph for '-' [U+2212], substituting with a dummy symbol.
    Font 'default' does not have a glyph for '-' [U+2212], substituting with a dummy symbol.
    Font 'default' does not have a glyph for '-' [U+2212], substituting with a dummy symbol.
    Font 'default' does not have a glyph for '-' [U+2212], substituting with a dummy symbol.
    
    In [152]:
    sns.scatterplot(data=planets, x='distance', y='orbital_period', hue='year')
    plt.yscale('log')
    plt.xscale('log')
    
    Font 'default' does not have a glyph for '-' [U+2212], substituting with a dummy symbol.
    Font 'default' does not have a glyph for '-' [U+2212], substituting with a dummy symbol.
    Font 'default' does not have a glyph for '-' [U+2212], substituting with a dummy symbol.
    Font 'default' does not have a glyph for '-' [U+2212], substituting with a dummy symbol.
    

    correlation analysis (상관관계 분석)

    • 귀무가설: 데이터 x와 y는 서로 선형적인 관계가 없다
    • p < 0.05 이면, 관계가 없는데 있다고 할 확률이 5% 미만이므로, 관계가 있는 것으로 주장
    • r (correlation coefficient) 의 값에 따라서 상관관계가 얼마나 강한지 알아볼 수 있다
    1. 0.1 < r < 0.3: 약한 상관관계
    2. 0.3 < r < 0.7: 보통 수준의 상관관계
    3. 0.7 < r < 1: 강한 상관관계
    4. r = 1: x=y 관계
    5. 0.1 > r: 상관관계 없음
    • r이 음수인 경우, 위의 관계성에 모두 -1을 곱한다
    In [154]:
    taxis = sns.load_dataset('taxis')
    
    In [155]:
    taxis
    
    Out[155]:
    pickupdropoffpassengersdistancefaretiptollstotalcolorpaymentpickup_zonedropoff_zonepickup_boroughdropoff_borough01234...64286429643064316432
    2019-03-23 20:21:09 2019-03-23 20:27:24 1 1.60 7.0 2.15 0.0 12.95 yellow credit card Lenox Hill West UN/Turtle Bay South Manhattan Manhattan
    2019-03-04 16:11:55 2019-03-04 16:19:00 1 0.79 5.0 0.00 0.0 9.30 yellow cash Upper West Side South Upper West Side South Manhattan Manhattan
    2019-03-27 17:53:01 2019-03-27 18:00:25 1 1.37 7.5 2.36 0.0 14.16 yellow credit card Alphabet City West Village Manhattan Manhattan
    2019-03-10 01:23:59 2019-03-10 01:49:51 1 7.70 27.0 6.15 0.0 36.95 yellow credit card Hudson Sq Yorkville West Manhattan Manhattan
    2019-03-30 13:27:42 2019-03-30 13:37:14 3 2.16 9.0 1.10 0.0 13.40 yellow credit card Midtown East Yorkville West Manhattan Manhattan
    ... ... ... ... ... ... ... ... ... ... ... ... ... ...
    2019-03-31 09:51:53 2019-03-31 09:55:27 1 0.75 4.5 1.06 0.0 6.36 green credit card East Harlem North Central Harlem North Manhattan Manhattan
    2019-03-31 17:38:00 2019-03-31 18:34:23 1 18.74 58.0 0.00 0.0 58.80 green credit card Jamaica East Concourse/Concourse Village Queens Bronx
    2019-03-23 22:55:18 2019-03-23 23:14:25 1 4.14 16.0 0.00 0.0 17.30 green cash Crown Heights North Bushwick North Brooklyn Brooklyn
    2019-03-04 10:09:25 2019-03-04 10:14:29 1 1.12 6.0 0.00 0.0 6.80 green credit card East New York East Flatbush/Remsen Village Brooklyn Brooklyn
    2019-03-13 19:31:22 2019-03-13 19:48:02 1 3.85 15.0 3.36 0.0 20.16 green credit card Boerum Hill Windsor Terrace Brooklyn Brooklyn

    6433 rows × 14 columns

    In [ ]:
     
    
    In [160]:
    sns.regplot(x=taxis['distance'], y=taxis['fare'])
    
    Out[160]:
    <AxesSubplot:xlabel='distance', ylabel='fare'>
    In [161]:
    # pearson correlation analysis
    # 정규성을 만족하고, 연속형 데이터인 경우
    stats.pearsonr(taxis['distance'], taxis['fare'])
    
    Out[161]:
    PearsonRResult(statistic=0.9201077027895748, pvalue=0.0)
    In [162]:
    # spearman correlation analysis
    # 정규성을 만족하지 않거나, 범주형 데이터인 경우
    stats.spearmanr(taxis['distance'], taxis['fare'])
    
    Out[162]:
    SpearmanrResult(correlation=0.9257442230436977, pvalue=0.0)
    In [ ]:
     
    

    실습

    • 아래 데이터를 확인한 뒤, x와 y의 상관관계를 알아보자
    • plot으로 결과를 출력한다
    In [163]:
    diamonds
    
    Out[163]:
    caratcutcolorclaritydepthtablepricexyz01234...5393553936539375393853939
    0.23 Ideal E SI2 61.5 55.0 326 3.95 3.98 2.43
    0.21 Premium E SI1 59.8 61.0 326 3.89 3.84 2.31
    0.23 Good E VS1 56.9 65.0 327 4.05 4.07 2.31
    0.29 Premium I VS2 62.4 58.0 334 4.20 4.23 2.63
    0.31 Good J SI2 63.3 58.0 335 4.34 4.35 2.75
    ... ... ... ... ... ... ... ... ... ...
    0.72 Ideal D SI1 60.8 57.0 2757 5.75 5.76 3.50
    0.72 Good D SI1 63.1 55.0 2757 5.69 5.75 3.61
    0.70 Very Good D SI1 62.8 60.0 2757 5.66 5.68 3.56
    0.86 Premium H SI2 61.0 58.0 2757 6.15 6.12 3.74
    0.75 Ideal D SI2 62.2 55.0 2757 5.83 5.87 3.64

    53940 rows × 10 columns

    In [166]:
    stats.shapiro(diamonds['x'])
    
    C:\ProgramData\Anaconda3\lib\site-packages\scipy\stats\_morestats.py:1800: UserWarning: p-value may not be accurate for N > 5000.
      warnings.warn("p-value may not be accurate for N > 5000.")
    
    Out[166]:
    ShapiroResult(statistic=0.9565654397010803, pvalue=0.0)
    In [167]:
    stats.shapiro(diamonds['y'])
    
    Out[167]:
    ShapiroResult(statistic=0.9186360836029053, pvalue=0.0)
    In [169]:
    r = stats.pearsonr(diamonds['x'], diamonds['y'])[0]
    p = stats.pearsonr(diamonds['x'], diamonds['y'])[1]
    
    In [175]:
    plt.figure(figsize=(6,4))
    sns.regplot(data=diamonds, x='x', y='y')
    plt.text(9,55,'r = %.4f' %r)
    plt.text(9,50,'p = %.4f' %p)
    
    Out[175]:
    Text(9, 50, 'p = 0.0000')
    In [180]:
    sns.regplot(data=diamonds, x='x', y='y', marker='*')
    plt.show()
    sns.regplot(data=diamonds, x='x', y='y', marker='o')
    plt.show()
    sns.regplot(data=diamonds, x='x', y='y', marker='+')
    plt.show()
    
    In [181]:
    import pandas as pd
    
    In [183]:
    df = pd.read_csv('F:/신입강의/data/서울시 부동산 실거래가 정보.csv', encoding='cp949')
    
    C:\Users\user\AppData\Local\Temp\ipykernel_19228\2210474608.py:1: DtypeWarning: Columns (7,19,20) have mixed types. Specify dtype option on import or set low_memory=False.
      df = pd.read_csv('F:/신입강의/data/서울시 부동산 실거래가 정보.csv', encoding='cp949')
    

    실습

    • 땅값이 가장 비싼 자치구 Top 5를 알아보자
    • 설명을 덧붙여 주세요
    In [184]:
    df.head()
    
    Out[184]:
    접수연도자치구코드자치구명법정동코드법정동명지번구분지번구분명본번부번건물명...물건금액(만원)건물면적(㎡)토지면적(㎡)층권리구분취소일건축년도건물용도신고구분신고한 개업공인중개사 시군구명01234
    2023 11710 송파구 10600 삼전동 1.0 대지 43.0 3.0 더트라이앵글 ... 27000 16.59 12.15 3.0 NaN NaN 2021.0 연립다세대 중개거래 서울 송파구
    2023 11140 중구 16100 저동2가 1.0 대지 7.0 2.0 제이매크로 타워 ... 20300 19.35 31.04 9.0 NaN NaN 2018.0 오피스텔 중개거래 서울 중구
    2023 11260 중랑구 10300 중화동 1.0 대지 295.0 38.0 대일빌라 ... 13500 44.00 27.58 2.0 NaN NaN 1994.0 연립다세대 중개거래 서울 중랑구
    2023 11740 강동구 10900 천호동 1.0 대지 425.0 3.0 천호역 한강 푸르지오시티 ... 18800 25.24 35.91 28.0 NaN NaN 2015.0 오피스텔 중개거래 서울 강동구
    2023 11380 은평구 10800 역촌동 1.0 대지 80.0 2.0 임창에버빌(80-2) ... 22500 40.48 15.96 6.0 NaN NaN 2011.0 연립다세대 중개거래 서울 은평구

    5 rows × 21 columns

    In [217]:
    sns.barplot(data=df, x='자치구명', y='물건금액(만원)',
                palette='BuGn')
    plt.xticks(rotation=90)
    
    Out[217]:
    (array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
            17, 18, 19, 20, 21, 22, 23, 24]),
     [Text(0, 0, '송파구'),
      Text(1, 0, '중구'),
      Text(2, 0, '중랑구'),
      Text(3, 0, '강동구'),
      Text(4, 0, '은평구'),
      Text(5, 0, '동대문구'),
      Text(6, 0, '금천구'),
      Text(7, 0, '성동구'),
      Text(8, 0, '양천구'),
      Text(9, 0, '서대문구'),
      Text(10, 0, '도봉구'),
      Text(11, 0, '강북구'),
      Text(12, 0, '동작구'),
      Text(13, 0, '관악구'),
      Text(14, 0, '영등포구'),
      Text(15, 0, '구로구'),
      Text(16, 0, '서초구'),
      Text(17, 0, '강서구'),
      Text(18, 0, '광진구'),
      Text(19, 0, '노원구'),
      Text(20, 0, '강남구'),
      Text(21, 0, '성북구'),
      Text(22, 0, '용산구'),
      Text(23, 0, '종로구'),
      Text(24, 0, '마포구')])
    In [218]:
    sort = ['강남구', '용산구', '서초구', '성동구', '동작구']
    
    In [222]:
    sns.barplot(data=df, x='자치구명', y='물건금액(만원)',
                palette='BuGn', order=sort, ci=False)
    plt.ylim(40000,150000)
    
    Out[222]:
    (40000.0, 150000.0)
    In [197]:
    sns.boxplot(data=df, x='자치구명', y='물건금액(만원)', palette='BuGn')
    plt.yscale('log')
    plt.xticks(rotation=90)
    
    Out[197]:
    (array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
            17, 18, 19, 20, 21, 22, 23, 24]),
     [Text(0, 0, '송파구'),
      Text(1, 0, '중구'),
      Text(2, 0, '중랑구'),
      Text(3, 0, '강동구'),
      Text(4, 0, '은평구'),
      Text(5, 0, '동대문구'),
      Text(6, 0, '금천구'),
      Text(7, 0, '성동구'),
      Text(8, 0, '양천구'),
      Text(9, 0, '서대문구'),
      Text(10, 0, '도봉구'),
      Text(11, 0, '강북구'),
      Text(12, 0, '동작구'),
      Text(13, 0, '관악구'),
      Text(14, 0, '영등포구'),
      Text(15, 0, '구로구'),
      Text(16, 0, '서초구'),
      Text(17, 0, '강서구'),
      Text(18, 0, '광진구'),
      Text(19, 0, '노원구'),
      Text(20, 0, '강남구'),
      Text(21, 0, '성북구'),
      Text(22, 0, '용산구'),
      Text(23, 0, '종로구'),
      Text(24, 0, '마포구')])
    In [226]:
    sns.boxplot(data=df, x='자치구명', y='물건금액(만원)',
                palette='BuGn', order=sort)
    plt.yscale('log')
    

    'Python > Jupyter notebook' 카테고리의 다른 글

    #11  (0) 2023.02.05
    #9  (0) 2023.01.16
    #8-3  (0) 2023.01.16
    #8-2  (0) 2023.01.16
    #8-1  (0) 2023.01.16
Designed by Tistory.