| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
- array
- PANDAS
- Kotlin
- dataframe
- PostgreSQL
- list
- google apps script
- GIT
- c#
- Redshift
- string
- django
- Presto
- Excel
- Apache
- hive
- Google Excel
- matplotlib
- Tkinter
- math
- PySpark
- 파이썬
- Python
- Java
- Google Spreadsheet
- Github
- SQL
- gas
- numpy
- Today
- Total
목록Python/Python Pandas (80)
달나라 노트
이 글에선 Pandas의 DataFrame에 groupby와 rolling method를 동시에 사용하는 예시를 보겠습니다. 이 글 이전에 아래 2개의 글을 먼저 읽고 오면 이해하는데 도움이 됩니다. https://cosmosproject.tistory.com/156 Python Pandas : rolling (DataFrame window function) 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.. cosmosproje..
min, max method를 이용하면 컬럼간의 값 비교가 가능해집니다. import pandas as pd import numpy as np dict_test = { 'col1': [1, 2, np.nan, 4, 5], 'col2': [6, 2, 7, 3, 9], 'col3': [10, 6, 22, np.nan, 21] } df_test = pd.DataFrame(dict_test) print(df_test) -- Result col1 col2 col3 0 1.0 6 10.0 1 2.0 2 6.0 2 NaN 7 22.0 3 4.0 3 NaN 4 5.0 9 21.0 먼저 test용 DataFrame을 위처럼 생성합시다. import pandas as pd import numpy as np dict_tes..
Pandas의 str.contains method는 특정 Series에 적용할 수 있으며 해당 Series에 있는 값들이 어떤 문자열을 포함하고있으면 True, 포함하고있지 않으면 False를 return합니다. Syntax Series.str.contains(string/pattern, case=True/False, regex=True/False) string/pattern : 찾을 문자열 또는 패턴 case : True일 경우 case sensitive(대소문자 구분), False일 경우 case insensitive(대소문자 구분 안함) regex : True일 경우 string/pattern을 regular expression pattern으로 인식. False일 경우 string/pattern을..
Pandas로 DataFrame을 다루다보면 DataFrame data를 database에 load해야 할 경우가 있습니다. 따라서 아래처럼 create table 구문을 실행시켜 database table을 생성하고 해당 tabe에 insert하는 방법을 사용한다고 가정해봅시다. create table test_table ( col1 varchar, col2 bigint, col3 double ) 위 예시는 column이 3개밖에 없어서 다행이지만 만약 column이 30개인 DataFrame을 insert하려고 한다면 위 create table syntax에 column 30개에 대한 datatype을 일일이 적어줘야 할것입니다. 이는 너무 번거로운 작업이 아닐 수 없죠. pandas에는 위처럼 특정..