일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- SQL
- math
- matplotlib
- hive
- PANDAS
- GIT
- numpy
- Excel
- google apps script
- string
- Tkinter
- array
- PostgreSQL
- dataframe
- Apache
- django
- Java
- c#
- 파이썬
- Github
- Google Excel
- Google Spreadsheet
- gas
- Kotlin
- list
- Redshift
- Python
- Mac
- Today
- Total
목록Python/Python Pandas (76)
달나라 노트
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..

Python Pandas에는 DataFrame을 복사하여 clipboard로 넣어주는 to_clipboard라는 기능을 제공합니다. import pandas as pd dict_test = { 'col1': [1, 2, 3, 4, 5], 'col2': [6, 7, 8, 9, 10], 'col3': [11, 12, 13, 14, 15] } df_test = pd.DataFrame(dict_test) df_test.to_clipboard(sep='\t', index=False) 위처럼 Test용 DataFrame을 만든 후 to_clipboard를 적용시킵니다. sep='\t'는 DataFrame의 column separator를 tab(\t)으로 하겠다는 뜻이고, index=False는 DataFrame의..