Machine Learning #6 Pandas Dataframe
1. Pandas Dataframe 형식으로 읽어오기 import pandas as pd df = pd.read_csv('./data_file/ex1.csv') print('\n', df) print('\n', pd.read_table('./data_file/ex1.csv', sep=',')) print('\n', pd.read_table('./data_file/ex2.csv', header=None, sep=',')) print('\n', pd.read_table('./data_file/ex2.csv', names=['a','b','c','d','message'])) names = ['a','b','c','d','message'] print('\n', pd.read_table('./data_file/e..
Machine Learning #5 Matplotlib
1. Default import pandas as pd import matplotlib.pyplot as plt import numpy as np #t = np.arange(0., 5., 0.2) #plt.plot(t, t,'r--', t, 0.5*t**2, 'bs:', 0.2*t**3, 'g^-') np.random.seed(12345) f1 = plt.figure(figsize=(10,2)) plt.title('figsize:(10,2)') plt.plot(np.random.randn(100)) plt.savefig('ex_plot.png', dpi=400, bbox_inches='tight') plt.show() 2. Line Exx1 = np.linspace(0., 5.) x2 = np.linsp..
Machine Learning #4 Pandas
Pandas는 고수준의 자료구조와 파이썬을 통한 빠르고 쉬운 Series- 일련의 객체를 담을 수 있는 1차원 벡터- index(색인)라고 하는 배열의 데이터에 연관되 이름을 가지고 있다. import pandas as pd import numpy as np obj = pd.Series([-4,7,-4,3]) print('\n',obj, '\n') print('\n',obj.values, '\n') print('\n',obj.index, '\n') obj2 = pd.Series([-4,7,-4,3], index=['d','b','a','c']) print('\n',obj2, '\n') print('\n',obj2.index, '\n') print('\n',obj2['a'], '\n') obj2['d'] ..