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 Date Parsing Issue in Arrow Parser for CSV Files (#59904) #60054

Closed
7 changes: 7 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3223,6 +3223,13 @@ def combine_first(self, other) -> Series:
"""
from pandas.core.reshape.concat import concat

def replace_none_with_nan(series):
series.fillna(value=np.nan, inplace=True)

"""Apply the function to both Series"""
replace_none_with_nan(self)
replace_none_with_nan(other)

if self.dtype == other.dtype:
if self.index.equals(other.index):
return self.mask(self.isna(), other)
Expand Down
8 changes: 8 additions & 0 deletions pandas/io/parsers/arrow_parser_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ def read(self) -> DataFrame:

dtype_backend = self.kwds["dtype_backend"]

# Handle missing date values by checking for timestamp columns
for i, field in enumerate(table.schema):
if pa.types.is_timestamp(field.type):
column = table.column(i).to_pandas()
column.fillna(pd.NaT, inplace=True)

table = table.set_column(i, field.name, pa.array(column))

# Convert all pa.null() cols -> float64 (non nullable)
# else Int64 (nullable case, see below)
if dtype_backend is lib.no_default:
Expand Down
Loading