pd.read_csv(thousands= ','), 차원이 다른 데이터를 차트로, 데이터프레임에서 데이터값의 콤마제거
해당 데이터 프레임에서 0세부터 100세 까지 나이대 별로 몇명이 있는지 시각화를 한다면 df2 = df.loc[ df["행정구역"].str.contains("삼청동"), "2019년07월_계_0세" : ].values # values 로 컬럼을 제외한 값만 가져온다. [in]df2 [out]array([[ 7, 9, 13, 12, 11, 11, 9, 11, 20, 18, 18, 23, 23, 19, 17, 16, 20, 25, 25, 27, 22, 35, 34, 29, 42, 38, 38, 32, 31, 36, 53, 32, 29, 42, 45, 29, 45, 50, 45, 52, 43, 36, 34, 29, 35, 33, 41, 37, 46, 48, 44, 47, 33, 46, 41, 40, 44, ..
2022. 11. 29.
Matplotlip Heat Maps : 밀도차트, 한글처리
Heat Maps : 밀도를 나타내는데 좋다.¶ In [304]: # displ 과 comb 의 관계를 나타내되, # 데이터가 많고 적음을 표시할 수 있도록 # heat map 으로 시각화 In [349]: plt.colormaps() Out[349]: ['magma', 'inferno', 'plasma', 'viridis', 'cividis', 'twilight', 'twilight_shifted', 'turbo', 'Blues', 'BrBG', 'BuGn', 'BuPu', 'CMRmap', 'GnBu',..
2022. 11. 28.
Matplotlip 히스토그램, 갯수범위지정, bins, subplot
# 구간을 설정하여, 해당 구간에 포함되는 데이터가 몇개인지(갯수) # 세는 차트를 히스토그램이라고 한다. # 구간을, bin 이라고 부른다. # 구간이 여러개니까, bins 라고 부른다. # 히스토그램은, 똑같은 데이터를 가지고, # bin을 어떻게 잡느냐에 따라서, 차트 모양이 달라져서, # 해석을 다르게 할 수 도있다. df['speed'].describe() count 807.000000 mean 65.830235 std 27.736838 min 5.000000 25% 45.000000 50% 65.000000 75% 85.000000 max 160.000000 Name: speed, dtype: float64 plt.hist(data = df, x = 'speed') plt.show() # bi..
2022. 11. 28.
Pandas concat(), merge() 여러 데이터 프레임을 하나로 합치는 방법
CONCATENATING AND MERGING¶ Reference: https://pandas.pydata.org/pandas-docs/stable/merging.html In [4]: import pandas as pd In [5]: df1 = pd.DataFrame({'A': ['A0', 'A1', 'A2', 'A3'], 'B': ['B0', 'B1', 'B2', 'B3'], 'C': ['C0', 'C1', 'C2', 'C3'], 'D': ['D0', '..
2022. 11. 25.
Pandas 데이터프레임 오름차순, 내림차순 정렬 .Sort_values() ,sort_index()
SORTING AND ORDERING¶ In [41]: df = pd.DataFrame({'Employee ID':[111, 222, 333, 444], 'Employee Name':['Chanel', 'Steve', 'Mitch', 'Bird'], 'Salary [$/h]':[35, 29, 38, 20], 'Years of Experience':[3, 4 ,9, 1]}) df Out[41]: Employee ID Employee Name Salary [$/h] Years of Experience 0 111 Chanel 35 3 1 222 Steve 29 4 2 333 Mitch 38 9 3..
2022. 11. 25.
Pandas 사용자 정의 함수사용 .apply(), 판다스내장.str라이브러리
PANDAS OPERATIONS¶ In [2]: import pandas as pd In [3]: df = pd.DataFrame({'Employee ID':[111, 222, 333, 444], 'Employee Name':['Chanel', 'Steve', 'Mitch', 'Bird'], 'Salary [$/h]':[35, 29, 38, 20], 'Years of Experience':[3, 4 ,9, 1]}) df Out[3]: Employee ID Employee Name Salary [$/h] Years of Experience 0 111 Chanel 35 3 1 222 Steve ..
2022. 11. 25.
Pandas 카테고리컬, groupby(), 특정 데이터 가져오기
실습¶ In [1]: import pandas as pd import numpy as np # 책 제목과 작가, 그리고 유저별 별점 데이터가 있다. books = pd.Series(data = ['Great Expectations', 'Of Mice and Men', 'Romeo and Juliet', 'The Time Machine', 'Alice in Wonderland' ]) authors = pd.Series(data = ['Charles Dickens', 'John Steinbeck', 'William Shakespeare', ' H. G. Wells', 'Le..
2022. 11. 24.
Pandas NaN을 처리하는 전략 dropna(), fillna()
Dealing with NaN¶ In [150]: # We create a list of Python dictionaries items2 = [{'bikes': 20, 'pants': 30, 'watches': 35, 'shirts': 15, 'shoes':8, 'suits':45}, {'watches': 10, 'glasses': 50, 'bikes': 15, 'pants':5, 'shirts': 2, 'shoes':5, 'suits':7}, {'bikes': 20, 'pants': 30, ..
2022. 11. 24.