Skip to content

Commit

Permalink
fix get func so all date columns are read as dates (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyn4 authored Sep 23, 2024
1 parent 7c7c52b commit 803eb0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion gluestick/etl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,12 @@ def get(self, stream, default=None, catalog_types=False, **kwargs):
if catalog and catalog_types:
types_params = self.get_types_from_catalog(catalog, stream)
kwargs.update(types_params)
return pd.read_csv(filepath, **kwargs)
df = pd.read_csv(filepath, **kwargs)
# if a date field value is empty read_csv will read it as "object"
# make sure all date fields are typed as date
for date_col in kwargs.get("parse_dates", []):
df[date_col] = pd.to_datetime(df[date_col], errors='coerce')
return df

def get_metadata(self, stream):
"""Get metadata from parquet file."""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="gluestick",
version="2.1.23",
version="2.1.24",
description="ETL utility functions built on Pandas",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 803eb0c

Please sign in to comment.