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

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
Jump to file or symbol
Failed to load files and symbols.
+4 −2
Split
View
@@ -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')
@wesm

wesm Sep 12, 2012

Owner

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