일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Tkinter
- Mac
- django
- SQL
- array
- hive
- google apps script
- Google Excel
- Python
- matplotlib
- PANDAS
- Java
- math
- Excel
- Google Spreadsheet
- Apache
- string
- gas
- list
- Github
- Redshift
- c#
- numpy
- PySpark
- PostgreSQL
- 파이썬
- dataframe
- Kotlin
- GIT
- Today
- Total
목록Python (379)
달나라 노트
pandas의 values는 DataFrame에 적용하여 해당 DataFrame을 numpy arrary의 형태로 변환해줍니다. import pandas as pd dict_test = { 'col1': [1, 2, 3, 4, 5], 'col2': ['a', 'b', 'c', 'd', 'e'], 'col3': [6, 7, 8, 9, 10] } df_test = pd.DataFrame(dict_test) print(df_test) print(df_test.values) -- Result col1 col2 col3 0 1 a 6 1 2 b 7 2 3 c 8 3 4 d 9 4 5 e 10 [[1 'a' 6] [2 'b' 7] [3 'c' 8] [4 'd' 9] [5 'e' 10]] 위 예시를 보면 Test용 ..
pandas의 shape은 DataFrame에 적용해서 해당 DataFramedml 행/열(row/column) 개수를 tuple의 형태로 반환해줍니다. shape의 syntax는 다음과 같습니다. DataFrame.shape import pandas as pd dict_test = { 'col1': [1, 2, 3, 4, 5], 'col2': ['a', 'b', 'c', 'd', 'e'], 'col3': [6, 7, 8, 9, 10] } df_test = pd.DataFrame(dict_test) print(df_test) print(df_test.shape) -- Result col1 col2 col3 0 1 a 6 1 2 b 7 2 3 c 8 3 4 d 9 4 5 e 10 (5, 3) 위 예시를 보..
Python Pandas에서 제공하는 melt method는 가로 데이터를 세로 데이터로 변경해주는 기능을 가지고있습니다. (가로 데이터를 세로 데이터로 변경하는것을 보통 unpivot이라고 합니다.) Pandas pivot_table method와 반대의 개념이죠. Pandas pivot_table 참고 https://cosmosproject.tistory.com/29 Python Pandas : pandas.pivot_table pandas.pivot_table pivot_table은 세로 데이터를 가로 데이터로 변경해주는 역할을 합니다. 먼저 테스트용 DataFrame을 생성합시다. import pandas as pd dict_1 = { 'dt': [20201201, 20201201, 2020120..
dropna function은 DataFrame에서 NaN value가 존재하는 행(row) 또는 열(column)을 제거해줍니다. dropna의 syntax는 다음과 같습니다. DataFrame.dropna(axis=0/1, how='any'/'all', subset=[col1, col2, ...], inplace=True/False) dropna에 들어갈 수 있는 parameter들은 더 많지만 일단 대표적인 것들만 보겠습니다. axis = 0/1 or 'index'/'columns' 0 or 'index' -> NaN 값이 포함된 row를 drop (default 값입니다.) 1 or 'columns' -> NaN 값이 포함된 column을 drop how = 'any'/'all' any -> ro..