| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- dataframe
- Kotlin
- Google Spreadsheet
- SQL
- Google Excel
- Github
- math
- matplotlib
- Excel
- GIT
- Python
- PANDAS
- 파이썬
- hive
- numpy
- array
- Java
- string
- google apps script
- c#
- Tkinter
- django
- Redshift
- list
- PostgreSQL
- Presto
- Apache
- PySpark
- gas
- Today
- Total
목록Python (387)
달나라 노트
Python의 strip, lstrip, rstrip은 다음과 같은 기능을 가집니다. strip = 문자열의 양쪽 끝에 있는 어떤 텍스트를 제거합니다. lstrip = 문자열의 왼쪽 끝에 있는 어떤 텍스트를 제거합니다. rstrip = 문자열의 오른쪽 끝에 있는 어떤 텍스트를 제거합니다. str_test = ' abcde ' str_stripped = '[' + str_test.strip() + ']' str_lstripped = '[' + str_test.lstrip() + ']' str_rstripped = '[' + str_test.rstrip() + ']' print(str_stripped) print(str_lstripped) print(str_rstripped) - Output [abcde] ..
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의..
Pandas에서는 어떤 list에 존재하는 요소가 대상 DataFrame이나 Series에 존재 하는지를 True(존재), False(존재안함)로 반환해주는 isin method를 제공합니다. import pandas as pd list_test = [1, 2, 3, 4, 5] seri_test = pd.Series(list_test) print(seri_test) print(type(seri_test)) - Output 0 1 1 2 2 3 3 4 4 5 dtype: int64 먼저 test용 Series를 만듭시다. seri_test_1 = seri_test.isin([1, 3, 5]) print(seri_test_1) print(type(seri_test_1)) - Output 0 True 1 Fa..