[읽을거리]
·
About Dev(Python)/Python comprehension
Six Rules for Deploying your Machine Learning Models Faster | by Mike Bernico | Towards Data Science - : https://towardsdatascience.com/six-rules-for-deploying-your-machine-learning-models-faster-b5b071a4a29e Six Rules for Deploying your Machine Learning Models Faster Data science and machine learning can improve almost any aspect of an organization, but only if your ideas get used. Over the las..
type 과 isinstance
·
About Dev(Python)/Python comprehension
둘다 타입을 확인할 수 있지만.... type(object) return object type isinstance(object, classinfo) return True | False * 예시 type(1.2) >> isinstance(1.2, float) >> True isinstance(1.2, int) >> False isinstance(1.2, (int,float,str)) >> True
[comprehension] List to Dictionary
·
About Dev(Python)/Python comprehension
List to Dict 에는 여러가지 방법이 있다. ## example ## string_list = ['A','B','C'] 1. Dictionary Comprehension 이용 dictionary = {string : 0 for string in string_list} print(dictionary) >> {'A':0, 'B':0 , 'C':0} 위 내용을 조금 변형해보자면 dictionary = {string : i for i, string in enumerate(sting_list)} print(dictionary) >> {'A': 0, 'B': 1, 'C': 2} 2. dict.fromkeys(key,value) 이용 dictionary = dict.fromkeys(string_list,0) ..
[문자열] 문자열 일치
·
About Dev(Python)/Python comprehension
1. 문자열 부분 일치 method : in , not in print('y' in 'python') >>> True print('n' not in 'python') >>> False print('pn' in 'python') >>> False 2. 앞부분 일치 method : startswith() str = 'python' print(str.startswith('py')) >>> True print(str.startswith('on')) >>> False 3. 뒷부분 일치 : endswith() str = 'python' print(str.endswith('on')) >>> True print(str.endswith('off')) >>> False
[Python] String 'isdigit()' Method
·
About Dev(Python)/Python comprehension
Python의 isdigit()은 문자열이 숫자로 구성되어 있는지 판별해준다 * 음수나 소숫점이 있을 경우에는 숫자임에도 불구하고 False를 리턴해준다 - 숫자로만 이루어져 있다면 True - 문자가 껴있다면 False >> str.isdigit() return True(False)
Generator?
·
About Dev(Python)/Python comprehension
제너레이터를 알기 위해서는 iteration, iterable, iterator를 먼저 알아보아야 한다. 1. Iteration : 반복/ 특정 횟수만큼 조건이 만족할 떄 까지 반복하는 형태 - for, while, recursive 2. iterable : 반복 가능한 형태의 객체 - list, tuple, string...file - 반복적으로 원소를 하나씩 꺼내올 수 있거나 - 반복적으로 원소에 접근이 가능한 형태 - 엄밀하게 따지면 객체내에 __iter__라는 메서드가 정의되어 있다면 iterable 객체다. 3. iterator - 반복 가능한 값을 생성할 수 있는 객체 - Python은 iterator를 통해 무한한 집합을 가정하는 것도 가능하다 - 엄밀하게 따지면 객체내에 __next__ 라..
*arg, *kargs
·
About Dev(Python)/Python comprehension
*arg : *arguments의 줄임말/ 여러개의 인자를 함수로 받고자 할 때 쓰임 - 튜플 형태로 인식된다 ** kwargs : keyword arguments/ (키워드 = 특정값) 형태로 함수를 호출할 떄 쓰임 - 딕셔너리 형태로 인식된다. {'키워드' : '특정 값'} 순서 함수의 파라미터 순서 : 일반변수, *변수, **변수 * 변수 > 여러개가 arguments로 들어올 때, 함수 내부에서는 해당 변수를 튜플로 처리한다 ** 변수 > 키워드=' '로 입력할 경우에 그것을 각각 키와 값으로 가져오는 딕셔너리로 처리한다
List Comprehension
·
About Dev(Python)/Python comprehension
1. List Comprehesion 기본...[i * i for i in range(10)]# 리스트에 입력될 값 + 반복문의 구조로 이해하면 편하다# 다만 2차원 이상은 만들지 않는 것이 좋다예시alist = [1,2,3,4,5]blist = [3,3,3,3,3][i * j for i,j in zip(alist,blist)]>> [3, 6, 9, 12, 15] 조건문을 만족하는 경우에만 만들게 할 수 도 있다[ 조건 만족 시 출력값 if 조건 else 조건 불만족 시 출력 값 for i in data] l = [22, 13, 45, 50, 98, 69, 43, 44, 1][x+1 if x >= 45 else x+5 for x in l]>>>[27, 18, 46, 51, 99, 70, 48, 49,..