Skip to content

Commit

Permalink
Merge pull request #132 from zypp-io/fix-bug-NaT
Browse files Browse the repository at this point in the history
Fix bug NaT
  • Loading branch information
TimvdHeijden authored Sep 6, 2024
2 parents 349d1e9 + aa1b854 commit 643c2b2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion df_to_azure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .export import df_to_azure as df_to_azure

__version__ = "1.0.0"
__version__ = "1.0.1"

logging.basicConfig(
format="%(asctime)s.%(msecs)03d [%(levelname)-5s] [%(name)s] - %(message)s",
Expand Down
2 changes: 1 addition & 1 deletion df_to_azure/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def upload_to_blob(self):
datetime_dtypes = self.df.select_dtypes("datetime")
if datetime_dtypes.empty is False:
for col in datetime_dtypes.columns:
self.df[col] = self.df[col].astype(str)
self.df[col] = self.df[col].astype(str).replace("NaT", None)
data = self.df.to_parquet(index=False)
blob_client.upload_blob(data, overwrite=True)

Expand Down
6 changes: 5 additions & 1 deletion df_to_azure/tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from keyvault import secrets_to_environment
from numpy import array, nan
from pandas import DataFrame, Series, date_range, read_sql_query, read_sql_table
from pandas import DataFrame, Series, date_range, read_sql_query, read_sql_table, NaT
from pandas._testing import assert_frame_equal

from df_to_azure import df_to_azure
Expand Down Expand Up @@ -44,6 +44,8 @@ def test_mapping_column_types():
"Categorical": Series(["a", "b", "c"], dtype="category"),
}
)
df["Date_with_nat"] = df["Date"]
df["Date_with_nat"].iloc[2] = NaT
df_to_azure(
df,
tablename="test_df_to_azure",
Expand All @@ -67,6 +69,7 @@ def test_mapping_column_types():
"Float",
"Float32",
"Date",
"Date",
"Timedelta",
"Bool",
"Categorical",
Expand All @@ -83,6 +86,7 @@ def test_mapping_column_types():
"numeric",
"numeric",
"datetime",
"datetime",
"numeric",
"bit",
"varchar",
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = df_to_azure
version = 1.0.0
version = 1.0.1
author = Zypp
author_email = hello@zypp.io
description = Automatically write pandas DataFrames to SQL by creating pipelines in Azure Data Factory with copy activity from blob to SQL
Expand Down

0 comments on commit 643c2b2

Please sign in to comment.