This is the sidebar. Without it, the main text is too wide!
- Genome project
- Linux
2019년 11월 교육 자료
- 실습용 스크립트 구글 문서라서 접속 환경에 따라 열리지 않을 수도 있습니다.
This is the sidebar. Without it, the main text is too wide!
2019년 11월 교육 자료
파이썬의 변수명에는 점('.')을 쓰면 안 된다. 점은 object class의 method 또는 attribute에 접근하는 방법이기 때문이다.
깊은 복사와 앝은 복사를 구별할 줄 알아야 한다.
연습용 데이터프레임 만들기
>>> import pandas as pd >>> data = {'col1': [1, 2, 3, 4], 'col2': [5, 6, 7, 8], 'col3': [9, 10, 11, 12]} >>> df = pd.DataFrame(data) >>> df col1 col2 col3 0 1 5 9 1 2 6 10 2 3 7 11 3 4 8 12 >>> import numpy as np >>> days_idx = pd.date_range('2022-04-01', periods=6) >>> data_2 = np.random.normal(size=24) >>> df_2 = pd.DataFrame(data_2.reshape(6,4), index=days_idx, columns=list('ABCD')) >>> df_2 A B C D 2022-04-01 -0.487410 -0.646506 -1.594448 0.036528 2022-04-02 -1.010553 1.055117 0.193330 -0.988199 2022-04-03 -1.314557 -0.281099 -0.616557 0.805412 2022-04-04 0.797291 -0.516087 0.017214 -0.202845 2022-04-05 -0.381635 0.142552 1.491784 -1.197995 2022-04-06 1.643891 -1.149778 -0.555952 -0.747896
참조: https://brownbears.tistory.com/421
아직도 새로운 방법이 나온다니 정말 놀랍다. str.format을 쓰는 방법과 f-string을 쓰는 방법 전부를 알아두자. % operator를 쓰는 구식 방법은 나와 같은 '신세대 파이썬 입문자'는 몰라도 될 것 같다. f-string을 쓸 때에는 인쇄할 변수를 나중에 선언해도 된다고 하니 이것 역시 놀랍다.
>>> import os >>> print(f'Current directory is {os.getcwd()}') Current directory is C:\Users\jeong\01_데이터캠퍼스 빅데이터 콘서트\01_0215 >>> print('Current directory is {}'.format(os.getcwd())) Current directory is C:\Users\jeong\01_데이터캠퍼스 빅데이터 콘서트\01_0215 >>> files = os.listdir(os.curdir) >>> files ['code_1st_0215.ipynb', 'Fixed_Length.csv', 'image_cat', 'image_dog', 'Image_X_test.csv', 'Image_X_train.csv', 'Image_y_test.csv', 'Image_y_train.csv', 'Text_Data_Full.csv', 'Text_X_test.csv', 'Text_X_train.csv', 'Text_y_test.csv', 'Text_y_train.csv']