목록Language (123)
우노
pip란? 파이썬의 장점 중 하나는, 다양한 패키지들을 지원한다는 것이다. 패키지는 numpy, beautifulsoup 등이 있으며, 해당 패키지들은 파이썬으로 작성되어 있다. pip는 파이썬 개발에 필요한 패키지들을 설치 및 관리하기 위한 명령어이다. python3 및 pip3 설치 (Ubuntu) python3 설치 시, pip3 설치 sudo apt-get update -y sudo apt-get install python3 pip3 -y python3 --version pip3 --version pip3 만 따로 설치 sudo apt-get update -y sudo apt-get install python3-pip pip3 --version pip 명령어 정리 pip list 현재 내 컴퓨터에..
matplotlib.pyplot.figure reference https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.html example import matplotlib.pyplot as plt # figure 크기 설정 plt.figure(figsize=(15,7)) # grid 설정 plt.grid(True) # title 설정 plt.title() # x, y축 라벨 설정 plt.xlabel() plt.ylabel() # x, y축 범위 설정 plt.xlim() plt.xlim() # x, y축 눈금 설정 plt.xticks() plt.yticks() # 범례 plt.legend() # 그리기 plt.plot() # 보이기 plt.show() m..
에러 원인 및 해결 에러 메세지 Error in optFederov(data = input, nTrials = 2, nRepeats = 1, criterion = "D") : nTrials must be greater than or equal to the number of columns in expanded X 원인 및 해결 nTrials 의 값은 data 열의 수보다 같거나 많게 설정해야한다. 에러 원인 및 해결 에러 메세지 Error in optFederov(data = input, nTrials = 1035, nRepeats = 1, criterion = "D") : Singular design. 에러 원인 및 해결 data 열 간 산술 연산한 값이, 추가적인 data 열에 존재하는 경우이므로, 산..
DataFrame 생성 import pandas as pd data = {'name':['michael','louis','jack','jasmine'], 'grades':[90,80,70,60], 'result':['N/A','N/A','N/A','N/A']} df = pd.DataFrame(data,columns=['name','grades','result']) # name grades result #0 michael 90 N/A #1 louis 80 N/A #2 jack 70 N/A #3 jasmine ..
scala.util.matching.Regex 란? scala에서는 scala.util.matching.Regex를 통해 정규표현식을 사용할 수 있으며, 정규표현식을 통해 패턴을 정의하고, 문자열에 패턴을 적용해 원하는 정보만 추출할 수 있다. 예제 코드 정규표현식으로 사용할 패턴 뒤에 .r 을 붙이면, 알아서 Regex 타입의 인스턴스가 생성된다. // 문자열 정의 val sentence = "11-aA_bB_cC_dD-22" // 정규표현식을 통해 패턴 정의 val pattern = "[a-zA-Z_]+".r // 문자열에서 정규표현식에 해당하는 패턴만 추출 val matches = pattern.findAllIn(sentence) println(matches.toList) // List(aA_bB_..
Dictionary 생성 dic = {'A' : 2, 'D' : 4, 'C' : 3, 'B' : 1} Key 오름차순 정렬 sort_dic = sorted( dic.items() ) # [('A', 2), ('B', 1), ('C', 3), ('D', 4)] Key 내림차순 정렬 sort_dic = sorted( dic.items(), reverse = True ) # [('D', 4), ('C', 3), ('B', 1), ('A', 2)] Value 오름차순 정렬 sort_dic = sorted( dic.items(), key = l..
zip 여러 개의 순회 가능한(iterable)한 객체를 인자로 전달 받고, 각 객체가 담고 있는 원소를 차례대로 접근하며 튜플의 형태로 묶고, 요소 개수만큼의 새로운 iterable 객체를 생성하는 기능입니다. 예제 코드 list1 = ['a', 'b', 'c'] list2 = [1, 2, 3] pairs = [pair for pair in zip(list1, list2)] print(pairs) # [('a', 1), ('b', 2), ('c', 3)] 인자 언패킹(argument unpacking) packing 은 여러 객체를 하나의 객체로 합치는 기능이라면, unpacking 은 여러 객체를 포함하고 있는 객체..
특성 리스트와 마찬가지로 요소 변경이 불가능 하다. 하지만, 리스트와 달리 다른 타입의 요소를 넣을 수 있다. 보통 메소드에서 여러 다양한 객체를 리턴해야 하는 경우 유용하다. 생성 요소를 콤마로 구분지어 생성한다. 아래 튜플 타입은 Tuple2[Int, String] 이며, 요소의 개수와 각각의 타입에 따라 튜플의 타입이 달라진다. 튜플 타입은 22개까지 지원하며 ('a',b',"cde")의 타입은 Tuple3[Char, Char, String] 이다. val t = (99, "High") 요소 접근 튜플의 index는 0이 아닌 1부터 시작하며, _1, _2 와 같이 접근한다. // 튜플의 첫 번째 요소에 접근 t._1 참고 https://hamait.tistory.com/557..
Anaconda에 설치된 Python 버전 확인 conda search python Anaconda Python 버전 변경 # conda install python=원하는 파이썬 버전 conda install python=3.7.0
예제 코드 import matplotlib.pyplot as plt plt.rc('font', size=20) # 기본 폰트 크기 plt.rc('axes', labelsize=20) # x,y축 label 폰트 크기 plt.rc('xtick', labelsize=50) # x축 눈금 폰트 크기 plt.rc('ytick', labelsize=20) # y축 눈금 폰트 크기 plt.rc('legend', fontsize=20) # 범례 폰트 크기 plt.rc('figure', titlesize=50) # figure title 폰트 크기 참고 https://bjy2.tistory.com/82