일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Google Excel
- 파이썬
- hive
- gas
- list
- string
- c#
- google apps script
- Github
- SQL
- PostgreSQL
- GIT
- numpy
- Tkinter
- Apache
- PANDAS
- array
- Redshift
- PySpark
- Kotlin
- dataframe
- Java
- Excel
- matplotlib
- Google Spreadsheet
- Python
- Mac
- math
- django
- Today
- Total
목록Python/Python Pandas (76)
달나라 노트
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..
pandas.to_numeric to_numeric은 데이터를 숫자 형식으로 바꿔주는 역할을 합니다. to_numeric의 대표적 인자는 아래와 같습니다. pd.to_numeric(숫자로 변경할 대상, errors='ignore/raise/coerce') 숫자로 변경할 대상: to_numeric을 적용시켜 숫자형식으로 변경시킬 대상이며 스칼라값, list, tuple, Series 등이 대상으로 지정될 수 있습니다. errors: error는 총 3개의 옵션이 존재합니다. - errors = 'ignore' -> 만약 숫자로 변경할 수 없는 데이터라면 숫자로 변경하지 않고 원본 데이터를 그대로 반환합니다. - errors = 'coerce' -> 만약 숫자로 변경할 수 없는 데이터라면 기존 데이터를 지우..
pandas.pivot_table pivot_table은 세로 데이터를 가로 데이터로 변경해주는 역할을 합니다. 먼저 테스트용 DataFrame을 생성합시다. import pandas as pd dict_1 = { 'dt': [20201201, 20201201, 20201201, 20201201, 20201202, 20201202, 20201202, 20201202, 20201203, 20201203, 20201203, 20201203], 'item_id': [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2], 'item_name': ['a', 'a', 'b', 'b', 'a', 'a', 'b', 'b', 'a', 'a', 'b', 'b'], 'price': [1000, 1100, 1000..
pandas.DataFrame.rename rename은 DataFrame의 column name이나 row index name을 변경해주는 역할을 합니다. 먼저 테스트용 DataFrame을 생성합시다. import pandas as pd dict_1 = { 'col1': [1, 2, 3, 4, 5], 'col2': [6, 7, 8, 9, 10], 'col3': [11, 12, 13, 14, 15] } df_1 = pd.DataFrame(dict_1) print(df_1) print(type(df_1)) - Output col1 col2 col3 0 1 6 11 1 2 7 12 2 3 8 13 3 4 9 14 4 5 10 15 이제 위에서 생성한 DataFrame의 컬럼명을 바꿔봅시다. import pa..