[Python] matplotlib module - bar( ) , pie( )
import matplotlib.pyplot as plt plt.bar( x, y, width = bar width, bottom = y start pt ) plt.pie( [pie size], labels = [labels], autopct = '%d', startangle = degree) - autopct = %d (정수), %f (실수), %.2f / %1.2f, %0.2f (소수 2자리 실수) - startangle 부터 CCW 방향으로. - explode - shadow - colors plt.axis('equal') - x-axis / y-axis scale 동일
[Python] matplotlib module - scatter( )
import matplotlib.pyplot as plt plt.scatter( x, y, s = size, c = 'color', marker = 'D' (diamond) ) plt.plot과 비교 marker = (5, 0) : 5각형 polygon, (5, 1) : star, (5, 2) : asterisk, (5, 3) : circle iris.csv로 scatter( ) plot
[Python] matplotlib module - plot( )
import matplotlib.pyplot as plt plt.plot(*args) - y value list, x default [0,1,2,3] - plt.show() : display figure, jupyter notebook에서는 필요없음 plt.ylable( 'str' ) plt.legend( ) - plt.plot( index = 'str' ) plt.axis( [ x축 시작, x축 끝, y축 시작, y축 끝 ] ) plt.title( 'str' ) plt.savefig('file name') 한번에 표현도 가능 (대신 label/legend 등 option은 불가) plt.xticks(x, ('G1', 'G2', 'G3', 'G4')) - 문자 지정 plt.yticks([10,20,30,..
[Python] pandas module - File IO
import pandas as pd - pandas module은 numpy와 달리 왠만한 table 형식의 File IO가 가능함 (csv, txt, html, excel, spss, sas, sql, json,... ) df.to_csv( filepath, sep=',' ) - From pandas to csv file df.read_csv( filepath, sep=',', names = [ ], index_col = 0 ) - From csv file to pandas - index 지정을 안해주면 첫 번째 row가 attr.가 됨. name으로 attr name 지정 후, index_col으로 설정 df.to_sql( ) - From pandas to sql df.read_sql( sql, co..
[Python] pandas module - Time Series Data
import pandas as pd - time series data는 Timestamp 형식의 index가 있는 데이터 - pandas DatatimeIndex class의 object로 생성 가능 *python standard library의 'datetime' module을 이용해서 구현됨 pd.to_datatime( [ date list ] ) - discrete한 년월일시분초 - 2021.2.4, 2021-02-04, 02/04/2021, Feb 4,2021 전부 가능 pd.date_range( ) - time range기반 정보 - periods (default : 매일) - freq = 's'(초), 'T'(분), 'H'(시), 'D'(일), 'B'(workday), 'W'(일요일), 'W-..