Programming Language/Python
2023.07.25
import numpy as np list_1 = [[1,1,1,1,1], [2,2,2,2,2]] list_2 = [[3,3,3,3,3]] list_3 = [[4,4,4,4,4]] array_1 = np.array(list_1) array_2 = np.array(list_2) array_combine = np.concatenate([array_1, array_2, list_3], axis=0) print(array_combine, array_combine.shape) array_row_sum = array_combine.sum(axis=1) print(array_row_sum, array_row_sum.shape) array_row_sum_reshape = array_row_sum.reshape((len..
Programming Language/Python
2023.07.25
import numpy as np temp_list_1 = [[1,2,3,4,5], [6,7,8,9,10]] temp_np_array_1 = np.array(temp_list_1) temp_list_2 = [[1,1,1,1,1], [2,2,2,2,2]] temp_np_array_2 = np.array(temp_list_2) print(temp_np_array_1) print(temp_np_array_2) print("행방향으로 합치기") array_row = np.concatenate([temp_np_array_1, temp_np_array_2], axis=0) print(array_row, array_row.shape, array_row.dtype) print("열방향으로 합치기") array_colu..
Programming Language/Python
2023.07.25
#1 행별, 열별 합 #2 행별, 열별 최대값 #3 행별, 열별 최소값 #4 행별, 열별 평균 #1 행별, 열별 합 import numpy as np temp_list = [[1,3,5,7,9], [2,4,6,8,10]] temp_np_array = np.array(temp_list) print(temp_np_array, temp_np_array.shape) print(temp_np_array.sum(axis=1)) print(temp_np_array.sum(axis=0)) #2 행별, 열별 최대값 import numpy as np temp_list = [[1,3,5,7,9], [2,4,6,8,10]] temp_np_array = np.array(temp_list) print(temp_np_array, ..
Programming Language/Python
2023.07.25
import numpy as np temp_list = [[1,3,5,7,9], [2,4,6,8,10]] temp_np_array = np.array(temp_list) print(temp_np_array, temp_np_array.shape) print(temp_np_array.sum()) print(temp_np_array.max()) print(temp_np_array.min()) print(temp_np_array.mean())
Programming Language/Python
2023.07.25
#1 1차원 리스트를 넘파이 어레이로 #2 2차원 리스트를 넘파이 어레이로 #3 3차원 리스트를 넘파이 어레이로 #1 1차원 리스트를 넘파이 어레이로 import numpy as np temp_list = [1,3,5,7,9] temp_np_array = np.array(temp_list) print(temp_list, type(temp_list), len(temp_list)) print(temp_np_array, type(temp_np_array), len(temp_np_array), temp_np_array.shape) #2 2차원 리스트를 넘파이 어레이로 import numpy as np temp_list = [[1,3,5,7,9], [2,4,6,8,10]] temp_np_array = n..
Programming Language/Python
2023.07.25
#1 랜덤 사용 #2 랜덤 여러번 출력 #3 랜덤 반복문에서 출력 #4 랜덤 고정 #1 랜덤 사용 import numpy as np random_list = np.random.randint(5, size=3) print(random_list) #2 랜덤 여러번 출력 import numpy as np random_list = np.random.randint(5, size=3) print(random_list) print(random_list) print(random_list) #3 랜덤 반복문에서 출력 import numpy as np for _ in range(5): random_list = np.random.randint(5, size=3) print(random_list) #4 랜덤 고정 import..
Programming Language/Python
2023.07.24
#1 yyyy-mm-dd 문자열을 datetime 타입으로 변경 #2 yy-mm-dd 문자열을 datetime 타입으로 변경 #3 yyyy-mm-ddTHH:MM:ss 문자열을 datetime 타입으로 변경 #4 yyyy-mm-dd HH:MM:ss 문자열을 datetime 타입으로 변경 #1 yyyy-mm-dd 문자열을 datetime 타입으로 변경 from datetime import datetime str_1 = "2023-01-07" print(str_1, type(str_1)) dt_1 = datetime.strptime(str_1, "%Y-%m-%d") print(dt_1, type(dt_1)) #2 yy-mm-dd 문자열을 datetime 타입으로 변경 from datetime import da..
Programming Language/Python
2023.07.24
#1 for문 속도 측정하기 #1 for문 속도 측정하기 import timeit def test_for(): for i in range(100): i += 1 t1 = timeit.repeat(stmt='test_for()', setup='from __main__ import test_for', number=10000, repeat=3) print(t1)
Programming Language/Python
2023.07.21
#1 str 타입 확인하기 #2 int 타입 확인하기 #3 float 타입 확인하기 #4 list 타입 확인하기 #5 dict 타입 확인하기 #6 set 타입 확인하기 #7 tuple 타입 확인하기 #1 str 타입 확인하기 temp_str = "park" temp_int = 15 temp_float = 1.53 temp_list = [1, 2] temp_dict = {"a": 1, "b": 2} temp_set = {1,2,3} temp_tuple = (1,2,3) print(isinstance(temp_str, str)) print(isinstance(temp_int, str)) print(isinstance(temp_float, str)) print(isinstance(temp_list, str))..
Programming Language/Python
2023.07.21
#1 문자열 출력 -> temp_str = "kim,park,choi" #2 문자열을 리스트로 만들기 #3 예외상황 (띄어쓰기) -> temp_str = "kim , park , choi" #4 예외상황 처리 (띄어쓰기) #5 예외상황 (반점만 찍힌 것들 무시하기) -> temp_str = "kim , park , choi,,,,,,," #6 예외상황 처리 (반점만 찍힌 것들 무시하기) #1 문자열 출력: temp_str = "kim,park,choi" temp_str = "kim,park,choi" print(temp_str) #2 문자열을 리스트로 만들기 temp_str = "kim,park,choi" temp_list = [value for value in temp_str.split(",")] pr..
'Programming Language' 카테고리의 글 목록 (3 Page)
닫기
단축키
내 블로그
내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W
블로그 게시글
글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C
모든 영역
이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /
* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.