Cording
-
learningCording/Python 2021. 2. 13. 01:24
Scikit-Learn 라이브러리 import pandas ad pd df = pd.read_csv(C:/myCode/data/basketball_stat.csv') data_df = df[0:100] data_df.head() from sklearn.model_selection import train_test_split # 학습데이터 80%, 테스트데이터 20%로 분리 train, test = train_test_split(data_df, best_size=0.2) train.shape # 일부만 가져옴. train_data_df = train[['3P',"BLK',"TRB']] train_label_df = train[["Pos']] tarin_data_df.head() # KNN 라이브 추가 fro..
-
for, 문자열Cording/Python 2021. 2. 5. 01:19
list1 = [] list2 = [] value = 1 for i in range(0, 3) : # 0, 1, 2 반복 for k in range(0, 4) : # 0, 1, 2, 3 반복 list1.append(value) value +=1 list2.append(list1) list1 = [] =========================== inStr = " 한글 python 프로그래밍 " outStr = "" for i in range(0, len(inStr)) : if inStr[i] != ' ' : outstr += instr[i] print("원래 문자열 ==> "+'[' + inStr + ']') print("공백 삭제 문자열 ==> " + '[' + outStr + ']') # 중첩된 ..
-
machine learningCording/Python 2021. 2. 1. 23:07
from sklearn.datasets import load_iris iris_dataset = load_iris() print("iris_dataset의 키 : {}".format(iris_dataset.keys())) print("타깃의 이름 : ", iris_dataset['feature_names']) print("data type : ", type(iris_dataset['data'])) print("size of data : ", iris_dataset['data'].shape) print("data : \n", iris_dataset['data'][:3]) print("target의 크기 : ", iris_dataset['target'].shape) print("target : ", iris..
-
전처리Cording/Python 2021. 1. 28. 21:24
import pandas as pd file_path = 'chipotle.tsv' chipo = pd.read_csv('chipotle.tsv', sep = '\t') chipo.head() chipo.shape print(chipo.info()) chipo.describe() chipo.columns chipo.index chipo['order_id'] = chipo['order_id'].astype(str) chipo.describe() item_count = chipo['item_name'].value_counts()[:10] # 상위 10개 item_count for index. (val, cnt) in enumerate(item_count.iteritems(), 1): print("Top", ..
-
GraphCording/Python 2021. 1. 22. 23:11
f = open('seoul.csv') data = csv.reader(f) next(data) result = [] for row in data: if row[-1] !='' : result.append(float(row[-1])) # print(result) plt.hist(result, bins=100, color = 'r') plt.show() f = open('seoul.csv') data = csv.reader(f) next(data) aug = [] for row in data: month = row[0].split('-')[1] : if row[-1] !='' : if month == '08' : aug.append(float(row[-1])) # print(aug) plt.hist(aug..
-
jupyter-data visualizationCording/Python 2021. 1. 21. 22:54
import csv f = open('seoul.csv') data = csv.reader(f) next(data) for row in data : print(row[-1]) > 마지막 열 f.close() import csv f = open('seoul.csv') data = csv.reader(f) next(data) result = [] for row in data : if row[-1] !='' : # != '같다는 표시(https://wikidocs.net/22216)' result append(float(row[-1])) print(result) f.close() print(len(result)) # 데이터 총 개수 import csv import matplotlib.pyplot as plt ..
-
Juypter-data2Cording/Python 2021. 1. 20. 22:58
import pandas as pd df = pd.read_csv('age.csv', encoding='cp949', index_col=0) df = df.div(df['총인구수'], axis = 0) del df['총인구수'], df['연령구간인구수'] df.head() name = input('원하는 지역의 이름을 입력해주세요 : ') a = df.index.str.contains(name) df2 = df[a] df2 # 데이터를 그래프로 그리기 위해 행과 열을 바꾸고 plot() 함수 실행 import matplotlib.pyplot as plt plt.rc('font', family='Malgun Gothic') df2.T.plot() plt.show()