User Tools

Site Tools


bioinfo:python_note

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
bioinfo:python_note [2022/04/27 22:25] – [print문 사용하기] hyjeongbioinfo:python_note [2022/04/28 22:22] (current) – [참고 웹사이트] hyjeong
Line 1: Line 1:
 ====== 파이썬 노트 ====== ====== 파이썬 노트 ======
 +===== 잡담 =====
 +
 파이썬의 변수명에는 점('.')을 쓰면 안 된다. 점은 object class의 method 또는 attribute에 접근하는 방법이기 때문이다. 파이썬의 변수명에는 점('.')을 쓰면 안 된다. 점은 object class의 method 또는 attribute에 접근하는 방법이기 때문이다.
 +
 +깊은 복사와 앝은 복사를 구별할 줄 알아야 한다.
 +
 +===== pandas.DataFrame =====
 +
  
 연습용 데이터프레임 만들기 연습용 데이터프레임 만들기
Line 14: Line 21:
   >>> import numpy as np   >>> import numpy as np
   >>> days_idx = pd.date_range('2022-04-01', periods=6)   >>> days_idx = pd.date_range('2022-04-01', periods=6)
-  >>> df_2 = pd.DataFrame(data.reshape(6,4), index=days_idx, columns=['A', 'B', 'C', 'D'])+  >>> data_2 = np.random.normal(size=24) 
 +  >>> df_2 = pd.DataFrame(data_2.reshape(6,4), index=days_idx, columns=list('ABCD'))
   >>> df_2   >>> df_2
                                              D                                              D
Line 23: Line 31:
   2022-04-05 -0.381635  0.142552  1.491784 -1.197995   2022-04-05 -0.381635  0.142552  1.491784 -1.197995
   2022-04-06  1.643891 -1.149778 -0.555952 -0.747896   2022-04-06  1.643891 -1.149778 -0.555952 -0.747896
-===== print문 사용기 =====+===== 인쇄를 위한 자열 포맷팅 방법 ===== 
 +참조: 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'
 +===== 참고 웹사이트 ===== 
 +  * [[https://wikidocs.net/book/1|점프 투 파이썬]] 
 +  * [[big data concert|빅데이터 콘서트]]
  
bioinfo/python_note.1651065924.txt.gz · Last modified: by hyjeong