일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- c#
- django
- Excel
- array
- Google Spreadsheet
- gas
- google apps script
- Mac
- list
- numpy
- Tkinter
- SQL
- hive
- Python
- string
- Google Excel
- Apache
- PostgreSQL
- Github
- matplotlib
- Redshift
- PySpark
- Java
- Kotlin
- math
- dataframe
- GIT
- PANDAS
- 파이썬
- Today
- Total
목록dataframe (22)
달나라 노트
groupby와 rank를 이용하면 window function에서 row_number() 함수와 같은 기능을 구현할 수 있습니다. import pandas as pdimport numpy as npdict_test = { 'col1': [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5], 'col2': [1000, 2000, 100, 300, 500, 200, 300, np.nan, 150, 180, 580, np.nan, 10, 100, 80, 55, 10]}df_test = p..
DataFrame에 있는 특징 한 가지를 알아보겠습니다. import pandas as pddict_test = { 'col1': [1, 2, 3, 4, 5], 'col2': [2, 3, 4, 5, 6],}df_test = pd.DataFrame(dict_test)df_test_1 = df_testdf_test_1.loc[:, 'col3'] = 3 df_test를 생성하고 df_test_1 = df_test 처럼 df_test_1에 df_test를 할당하였습니다. - df_test_1.loc[:, 'col3'] = 3그리고 df_test_1에 col3를 추가하였습니다. 그러면 df_test_1에만 col3가 생길까요?아니면 df_test에도 col3가 생길까요? 정답은 df_test에도 col..
Pandas의 columns는 DataFrame에 존재하는 Column의 정보를 출력해줍니다. import pandas as pddict_test = { 'col1': [1, 2, 3, 4, 5], 'col2': [2, 3, 4, 5, 6],}df_test = pd.DataFrame(dict_test)print(df_test)print(df_test.columns)-- Result col1 col20 1 21 2 32 3 43 4 54 5 6Index(['col1', 'col2'], dtype='object') list() method를 이용해서 column을 list의 형태로 만들 수도 있습니다. import ..
nunique() method는 DataFrame이나 Series에 있는 값들 중 중복값을 제거한 unique한 값의 개수를 return합니다. 바로 예시를 봅시다. import pandas as pd df_test = pd.DataFrame( { 'col1': [1, 1, 3, 3, 4, 4, 4], 'col2': [8, 8, 8, 8, 8, 9, 9], } ) print(df_test) nunique_result = df_test.nunique() print(nunique_result) print(type(nunique_result)) -- Result col1 col2 0 1 8 1 1 8 2 3 8 3 3 8 4 4 8 5 4 9 6 4 9 col1 3 col2 2 dtype: int64 df_t..