Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug NaT #132

Merged
merged 5 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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