-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from dcjohnson24/connection-timeout-workaround
Use full s3 URL for ConnectionTimeoutError
- Loading branch information
Showing
3 changed files
with
33 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import pandas as pd | ||
from pathlib import Path | ||
import data_analysis.compare_scheduled_and_rt as csrt | ||
|
||
def read_csv(filename: str | Path) -> pd.DataFrame: | ||
"""Read pandas csv from S3 | ||
Args: | ||
filename (str | Path): file to download from S3. | ||
Returns: | ||
pd.DataFrame: A Pandas DataFrame from the S3 file. | ||
""" | ||
if isinstance(filename, str): | ||
filename = Path(filename) | ||
s3_filename = '/'.join(filename.parts[-2:]) | ||
df = pd.read_csv( | ||
f'https://{csrt.BUCKET_PUBLIC}.s3.us-east-2.amazonaws.com/{s3_filename}', | ||
low_memory=False | ||
) | ||
return df | ||
|