일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Excel
- django
- hive
- math
- google apps script
- Redshift
- Apache
- matplotlib
- numpy
- gas
- Java
- PostgreSQL
- 파이썬
- PySpark
- c#
- array
- Python
- GIT
- Google Spreadsheet
- string
- Github
- PANDAS
- Mac
- SQL
- dataframe
- Kotlin
- Tkinter
- Google Excel
- list
- Today
- Total
목록Python/Python Pandas (77)
달나라 노트
requests library와 API를 이용하다보면 csv format의 데이터를 얻어올 때가 있습니다. 그 결과값은 API를 어떻게 만드냐에 따라 달라질 수 있지만 주로 보이는 형태는 아래와 같습니다. import requests api_endpoint = 'https://test_api/get_data' response = requests.get(api_endpoint) print(response.status_code) print(response.content) print(type(response.content)) -- Result 200 b'modelno,name,price,weight\r\nAGH1341,Laptop,1300000,1200\r\nSOE1029,Desktop,1800000,3500..
pandas의 read_json() method는 json 파일을 읽어와서 DataFrame으로 변환해주는 기능을 합니다. Syntax pandas.read_json(json_file, orient) - json_file 읽어올 json 파일의 경로와 이름입니다. (경로는 상대경로, 절대경로 모두 가능합니다.) - orient json 파일의 format입니다. columns, index, records, values, split의 다섯 종류가 있습니다. 각 orient 값이 어떠한 json format을 의미하는지는 본 글의 아래 부분에서 다루겠습니다. (format에 대한 자세한 설명은 다음 링크를 참고하시면 좋습니다. https://cosmosproject.tistory.com/684) fruits..
pandas의 to_json() method는 DataFrame을 json 파일로 생성해주는 기능을 가집니다. Syntax DataFrame.to_json(file_name, orient) - file_name 생성할 json 파일의 이름을 적습니다. json 파일은 test_file.json 처럼 json이라는 확장자를 갖습니다. - orient 생성할 json 파일의 format을 의미합니다. columns, index, records, values, split의 다섯 종류가 있습니다. 각각의 orient 값이 어떤 형태를 의미하는지는 예시를 통해 알아봅시다. import pandas as pd dict_test = { 'name': ['apple', 'banana', 'peach'], 'price'..
pandas의 empty는 Series 또는 DataFrame이 비어있으면 True를 return합니다. 반대로 비어있지 않으면 False를 return합니다. import pandas as pd dict_test = { } df_test = pd.DataFrame(dict_test) print(df_test) print(df_test.empty) -- Result Empty DataFrame Columns: [] Index: [] True 위 예시는 비어있는 DataFrame인 df_test를 만들고 df_test의 empty를 적용한 결과입니다. DataFrame에 column도 row도 아무것도 없으니 비어있죠. 따라서 True가 return됩니다. import pandas as pd dict_te..