목록"Today I Learned" 30일 프로젝트 (25)
IT와 비즈니스를 연결하다.
import numpy as np import pandas as pd pd.set_option('display.notebook_repr_html', False) pd.set_option('display.max_columns', 10) pd.set_option('display.max_rows', 10) Series 생성 & element 이용 s1 = pd.Series(2) s1 s1[0] s2 = pd.Series([1, 2, 3, 4, 5]) s2 s2.values s2.index s3 = pd.Series([1, 2, 3], index=['a', 'b', 'c']) s3 s3.index s3['c'] s4 = pd.Series(2, index=s2.index) s4 np.random.seed(1234..
n=int(input()) arr=list(map(int,input().split())) def quiksort(arr): p=arr[0] left, right, equal = [],[],[] for i in arr: if p>i: left.append(i) elif p
N = int(input()) L = [] for i in range(N): L.append(int(input())) #Bubble Sort for _ in range(len(L)): for i in range(len(L) - 1): if L[i] L[j]: min = j L[i], L[min] = L[min], L[i] for elem in L:..
number_of_numbers = int(input()) nums = [int(input()) for i in range(number_of_numbers)] def mergeSort(x): if len(x) > 1: mid_point = len(x)//2 left_x = x[:mid_point] right_x = x[mid_point:] mergeSort(left_x) mergeSort(right_x) left_index, right_index, x_index = 0, 0, 0 while left_index < len(left_x) and right_index < len(right_x): if left_x[left_index] < right_x[right_index]: x[x_index] = left_..
수정렬 https://www.acmicpc.net/problem/2750 def minimum_cut(): NM = list(map(int, input().split(' '))) return (NM[0] - 1) + (NM[1]-1)*NM[0] print(minimum_cut())
# Pandas 기초 import pandas as pd import numpy as np s = pd.Series([1,3,5,np.nan,6,8]) s s2 = pd.Series([92600, 92400, 92100, 94300, 92300], index=['2016-02-19', '2016-02-18', '2016-02-17', '2016-02-16', '2016-02-15']) s2 s2['2016-02-15'] dates = pd.date_range("20130101",periods=6) dates df = pd.DataFrame(np.random.randn(6,4), index=dates, columns=['A','B','C','D']) df df.head(3) df.index df.colum..
#클래스 var = "파이썬 객체 지향" print(id(var)) #var의 식별자확인 print(type(var)) #class 정의, 객체 생성, 멤버 출력 #self는 클래스의 인스턴스 객체를 가르키는 참조자 #slef 생략시 오류 class Myclass: var = "안녕하세요" def sayHello(self): print(self.var) obj = Myclass() print(obj.var) obj.sayHello() #(1) 클래스 정의 및 사용 class BookReader: name = str() def read_book(self): print(self.name + 'is reading Book!!') reader = BookReader() reader.name = "홍길동 " re..
import numpy as np import pandas as pd df = pd.DataFrame(np.arange(10, 22).reshape(3, 4), index = ["a","b","c"], columns = ["A","B","C","D"]) df # indexing 값 하나만 받는 경우 df.loc["a"] df.loc["b":"c"] df["b":"c"] df.loc[["b","c"]] # df[["b","c"]] # key error # indexing 값을 하나만 받는 경우 df.A > 15 df.loc[df.A > 15] def select_rows(df): return df.A > 15 df.loc[select_rows(df)] #df.loc["A"] # df.loc[["A","B"..