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

ENH: add more possible bool values to read_csv #1295 #1691

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 4 additions & 2 deletions pandas/src/inference.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,11 @@ def maybe_convert_bool(ndarray[object] arr):
for i from 0 <= i < n:
val = arr[i]

if val == 'True' or type(val) == bool and val:
true_vals = ('True', 'TRUE', 'true', 'Yes', 'YES', 'yes')
false_vals = ('False', 'FALSE', 'false', 'No', 'NO', 'no')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for future Python endeavors, I wouldn't recommend putting constant variables like these inside the for loop (very inefficient)

if val in true_vals or type(val) == bool and val:
result[i] = 1
elif val == 'False' or type(val) == bool and not val:
elif val in false_vals or type(val) == bool and not val:
result[i] = 0
else:
return arr
Expand Down