User Tools

Site Tools


bioinfo:python_note

This is an old revision of the document!


파이썬 노트

파이썬의 변수명에는 점('.')을 쓰면 안 된다. 점은 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)
>>> df_2 = pd.DataFrame(data.reshape(6,4), index=days_idx, columns=['A', 'B', 'C', 'D'])
>>> 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

문자열 포맷팅 방법

bioinfo/python_note.1651065984.txt.gz · Last modified: by hyjeong