일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Java
- gas
- SQL
- Tkinter
- numpy
- Mac
- Google Excel
- matplotlib
- c#
- Github
- Apache
- string
- Excel
- Redshift
- PostgreSQL
- django
- list
- dataframe
- Kotlin
- GIT
- hive
- Python
- PANDAS
- 파이썬
- array
- google apps script
- PySpark
- Google Spreadsheet
- math
- Today
- Total
목록Python/Python Pandas (77)
달나라 노트
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..
pandas.to_datetime to_datetime은 어떤 날짜를 나타내는 문자열을 정해진 format을 기반으로 Date 형식으로 바꿔주는 역할을 합니다. Pandas 공식 문서를 보면 굉장히 많은 인자가 to_datetime에 적용될 수 있지만 여기서는 한번 간단하게 실사용 위주로 알아봅시다. import pandas as pd x = pd.to_datetime('20200123') print(x) print(type(x)) x = pd.to_datetime('2020-01-23') print(x) print(type(x)) - Output 2020-01-23 00:00:00 2020-01-23 00:00:00 결과를 보면 20200123이라는 문자가 2020-01-23 00:00:00이라는 Ti..
DataFrame.to_excel &emp; DataFrame.to_csv &emp; pandas.ExcelWriter to_excel은 DataFrame 정보를 담아 xlsx 파일로 만들어주는 기능을 제공합니다. to_csv는 DataFrame 정보를 담아 csv 파일로 만들어주는 기능을 제공합니다. 먼저 test용 DataFrame을 생성합니다. import pandas as pd dict_1 = { 'col1': [1, 1, 1, 2, 3, 3, 3, 3, 4, 4, 5], 'col2': [1, 1, 1, 2, 3, 3, 3, 4, 4, 4, 5], 'col3': [1, 2, 3, 2, 2, 3, 3, 3, 3, 4, 4] } df_1 = pd.DataFrame(dict_1) print(df_1) ..

pandas.read_excel &emp; pandas.read_csv read_excel은 .xlsx 파일을 읽어 DataFrame의 형태로 가져오는 기능을 제공합니다. read_csv는 .csv 파일을 읽어 DataFrame의 형태로 가져오는 기능을 제공합니다. 엑셀을 실행하여 다음과 같은 데이터를 입력한 후 test.xlsx, test.csv라는 이름으로 동일한 데이터를 가진 2개의 파일을 생성하였습니다. 각각의 파일은 root directory(~/)의 Documents 폴더해 저장해놨기 때문에 경로를 이처럼 지정해주고 아래처럼 read_excel과 read_csv를 이용하여 파일을 읽어봅시다. xlsx_dir = '~/Documents/test.xlsx' csv_dir = '~/Documents..