| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- list
- SQL
- Apache
- Java
- google apps script
- string
- numpy
- Kotlin
- c#
- math
- hive
- PostgreSQL
- Redshift
- Presto
- django
- GIT
- Google Spreadsheet
- Excel
- gas
- Github
- 파이썬
- array
- matplotlib
- Python
- PySpark
- dataframe
- PANDAS
- Google Excel
- Tkinter
- Today
- Total
목록Python (387)
달나라 노트
Pandas에선 DataFrame에 존재하는 Data를 정렬하기 위한 sort_values라는 함수를 제공합니다. import pandas as pd dict_test = { 'col1': [3, 1, 2, 3, 2, 1], 'col2': ['b', 'a', 'd', 'e', 'y', 'z'] } df_test = pd.DataFrame(dict_test) print(df_test) print(type(df_test)) - Output col1 col2 0 3 b 1 1 a 2 2 d 3 3 e 4 2 y 5 1 z 먼저 테스트용 DataFrame을 만듭시다. df_test_sorted = df_test.sort_values(by=['col1'], ascending=True) print(df_test_s..
Pandas에서는 DataFrame에 있는 Column들의 Data type을 바꾸기 위해 astype이라는 method를 제공합니다. import pandas as pddict_test = { 'col1': [1, 2, 3, 4, 5], 'col2': [1.0, 2.0, 3.0, 4.0, 5.0], 'col3': ['1.2', '2.3', '3.4', '4.5', '5.6'],}df_test = pd.DataFrame(dict_test)print(df_test)print(type(df_test))print('col1 dtype :', df_test['col1'].dtype)print('col2 dtype :', df_test['col2'].dtype)print('col3 dtype :'..
Pandas의 concat은 두 개 이상의 Series를 합치거나, 두 개 이상의 DataFrame을 합쳐줍니다. import pandas as pd list_test_1 = [1, 2, 3] list_test_2 = [4, 5, 6] list_test_3 = [7, 8, 9] seri_test_1 = pd.Series(list_test_1) seri_test_2 = pd.Series(list_test_2) seri_test_3 = pd.Series(list_test_3) print(seri_test_1) print(seri_test_2) print(seri_test_3) - Output 0 1 1 2 2 3 dtype: int64 0 4 1 5 2 6 dtype: int64 0 7 1 8 2 9 dty..
Pandas의 Series에는 value_counts라는 method가 존재합니다. 이것은 Series에 존재하는 값들 중 동일한 값들이 몇 개 있는지를 세어줍니다. import pandas as pd list_test = [1, 2, 3, 3, 3, 4, 5, 5, 6, 7, 8, 8, 8, 9] seri_test = pd.Series(list_test) - Output 0 1 1 2 2 3 3 3 4 3 5 4 6 5 7 5 8 6 9 7 10 8 11 8 12 8 13 9 dtype: int64 먼저 위처럼 test용Series를 만들어줍시다. val_cnt = seri_test.value_counts() print(val_cnt) print(type(val_cnt)) - Output 8 3 3 3..