일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- PySpark
- Google Excel
- Github
- google apps script
- gas
- django
- 파이썬
- Java
- PANDAS
- PostgreSQL
- GIT
- hive
- numpy
- c#
- Google Spreadsheet
- Redshift
- list
- Tkinter
- Apache
- Python
- array
- matplotlib
- Kotlin
- Mac
- math
- string
- SQL
- Excel
- dataframe
- Today
- Total
목록Python/Python Pandas (77)
달나라 노트
dropna function은 DataFrame에서 NaN value가 존재하는 행(row) 또는 열(column)을 제거해줍니다. dropna의 syntax는 다음과 같습니다. DataFrame.dropna(axis=0/1, how='any'/'all', subset=[col1, col2, ...], inplace=True/False) dropna에 들어갈 수 있는 parameter들은 더 많지만 일단 대표적인 것들만 보겠습니다. axis = 0/1 or 'index'/'columns' 0 or 'index' -> NaN 값이 포함된 row를 drop (default 값입니다.) 1 or 'columns' -> NaN 값이 포함된 column을 drop how = 'any'/'all' any -> ro..
Python에 있는 notna method는 dataframe이나 seires에 적용하여 dataframe이나 series에 있는 값들이 누락값(NaN, null 등)인지를 체크합니다. 누락값이라면 False를 누락값이 아닌 어떠한 정상적인 값이 입력되어있다면 True를 반환합니다. import pandas as pd import numpy as np dict_test = { 'col1': [1, np.NaN, 3, 4, np.NaN], 'col2': ['a', 'b', 'c', 'd', 'e'] } df_test = pd.DataFrame(dict_test) # 1 print(df_test) print(df_test.notna()) # 2 sr_test = df_test['col1'] # 3 print..
Pandas에서 사용할 수 있는 window function 기능을 알아봅시다. import pandas as pd dict_test = { 'col1': [1, 1, 2, 2, 3, 3, 3, 4], 'col2': [1000, 1100, 2100, 2050, 3000, 3100, 3200, 4200], 'col3': ['a', 'b', 'a', 'c', 'a', 'a', 'd', 'e'] } df_test = pd.DataFrame(dict_test) # print(df_test) # print(type(df_test)) - Output col1 col2 col3 0 1 1000 a 1 1 1100 b 2 2 2100 a 3 2 2050 c 4 3 3000 a 5 3 3100 a 6 3 3200 d 7..
DataFrame의 fillna는 DataFrame에 존재하는 NaN값을 어떠한 값으로 채워줍니다. import pandas as pd import numpy as np dict_test = { 'col1': [1, 2, np.nan, 4, np.nan], 'col2': [np.nan, 'a', 'b', np.nan, 'z'], } df_test = pd.DataFrame(dict_test) print(df_test) df_filled = df_test.fillna('n') print(df_filled) - Output col1 col2 0 1.0 NaN 1 2.0 a 2 NaN b 3 4.0 NaN 4 NaN z col1 col2 0 1 n 1 2 a 2 n b 3 4 n 4 n z 위 예시를 보면 d..