We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 04eacaf commit c6f09e8Copy full SHA for c6f09e8
pandas_to_postgres/utilities.py
@@ -101,13 +101,11 @@ def cast_pandas(df, sql_table):
101
for col in sql_table.columns:
102
if str(col.type) in ["INTEGER", "BIGINT"]:
103
df[col.name] = df[col.name].apply(
104
- # np.nan are not comparable, so use str value
105
- lambda x: None if str(x) == "nan" else int(x),
106
- convert_dtype=False,
+ lambda x: None if pd.isna(x) else int(x), convert_dtype=False
107
)
108
elif str(col.type) == "BOOLEAN":
109
110
- lambda x: None if str(x) == "nan" else bool(x), convert_dtype=False
+ lambda x: None if pd.isna(x) else bool(x), convert_dtype=False
111
112
113
return df
0 commit comments