-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix using dtype with parse_dates in read_csv #34330
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
Changes from all commits
c94b45e
0ab450b
54c7304
6d72a34
5ba54a6
2766270
b800207
6b8f562
91176ca
f748b78
3c13f59
c04c494
d9aa319
0afb1b1
85dd0d6
4b53bf7
b3d5ca5
4175b80
6a78220
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1695,7 +1695,9 @@ def _convert_to_ndarrays( | |
result = {} | ||
for c, values in dct.items(): | ||
conv_f = None if converters is None else converters.get(c, None) | ||
if isinstance(dtypes, dict): | ||
if values.dtype != object: | ||
cast_type = values.dtype | ||
elif isinstance(dtypes, dict): | ||
cast_type = dtypes.get(c, None) | ||
else: | ||
# single dtype or None | ||
|
@@ -3249,6 +3251,9 @@ def _make_date_converter( | |
): | ||
def converter(*date_cols): | ||
if date_parser is None: | ||
date_cols = tuple( | ||
x if isinstance(x, np.ndarray) else x.to_numpy() for x in date_cols | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is better off done inside concat_date_cols, but what is the incoming data here in the example? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's tuple with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it possible to move this to |
||
strs = parsing.concat_date_cols(date_cols) | ||
|
||
try: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is very odd to do as we already have a path for a single dtype, what are you trying to do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After loading values from csv we have dictionary with column names and numpy array for each column with
dtype=object
. Then we change values that are suppose to be datetime ('b'
in example). After that we want to change types of the rest of columns, that is those that havedtype=object
. In that line we're skiping columns that already have dtype set.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
is_object_dtype(values.dtype)
to do the check