■ read_csv 함수를 사용해 특정 URL을 갖는 압축된 CSV 파일을 읽는 방법을 보여준다.
▶ main.py
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 |
import pandas as pd urlString = "https://s3-us-west-2.amazonaws.com/streamlit-demo-data/uber-raw-data-sep14.csv.gz" rowCount = 1000 dataFrame = pd.read_csv(urlString, nrows = rowCount) print(dataFrame) """ Date/Time Lat Lon Base 0 9/1/2014 0:01:00 40.2201 -74.0021 B02512 1 9/1/2014 0:01:00 40.7500 -74.0027 B02512 2 9/1/2014 0:03:00 40.7559 -73.9864 B02512 3 9/1/2014 0:06:00 40.7450 -73.9889 B02512 4 9/1/2014 0:11:00 40.8145 -73.9444 B02512 .. ... ... ... ... 995 9/2/2014 11:11:00 40.7381 -73.9878 B02512 996 9/2/2014 11:14:00 40.7848 -73.9560 B02512 997 9/2/2014 11:14:00 40.7848 -73.9560 B02512 998 9/2/2014 11:17:00 40.7741 -73.9608 B02512 999 9/2/2014 11:18:00 40.7410 -73.7579 B02512 [1000 rows x 4 columns] """ |
▶ requirements.txt
1 2 3 4 5 6 7 8 |
numpy==2.0.0 pandas==2.2.2 python-dateutil==2.9.0.post0 pytz==2024.1 six==1.16.0 tzdata==2024.1 |
※ pip install pandas 명령을 실행했다.