본문 바로가기

공부는 언제까지 해야 하나

(13)
[Python] matplotlib module - hist( ), boxplot( ), heatmap / Seaborn module import matplotlib.pyplot as plt plt.hist( [list] , range = [ x axis range], bins = 10(default) , label = 'str' ) plt.legend( ) - np.historam ([list]) 는 array로만 return plt.boxplot( [data] ) - notch : median 값의 1sigma 신뢰구간 표현 - sym = outlier 모양 , ' ' 하면 no outlier - vert = 0 : horizontal box, default = 1(vertical box ) - plt.boxplot([ data, data2 ...]) 도 가능 plt.figure( ) plt.subplot( ) plt.clf( ) ..
[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-..
[Python] pandas module - DataFrame object import pandas as pd DataFrame : 2D Array of Indexed Data df.set_index('Day') - Day를 index로 지정 df[ a : b ] - lavel 기준, [ a, b ) row table return df[ a ] - label기준, a row information return df.loc[ a : b ] - label 기준, [ a, b ] row table return df.iloc[ a : b ] - row 순서 기준, [ a, b ) row table return Add a new row / Delete an existing row pd.DataFrame(df2, columns = ['Revenue', 'Visitor']) - column ..
[Python] pandas module - Series object import pandas as pd import numpy as np pd.Series( ndarray_a ) : Series는 pandas module의 class 중 하나임 - dtype (default) : 'int64' / 'float64' , dtype(np.nan) = float - default index는 0, 1, 2, ... - index parameter에 list를 넣어주면 list처럼 indexing됨 - index 차이에 따른 두 series의 summation - index가 다르면 concatenation / index가 같으면 summation a.name = 'Series name' a.index.name = 'Index name' Series creation from d..