Pandas read_csv, reading a boolean with missing values specified as an int
问题 I am trying to import a csv into a pandas dataframe. I have boolean variables denoted with 1's and 0's, where missing values are identified with a -9. When I try to specify the dtype as boolean, I get a host of different errors, depending on what I try. Sample data: test.csv var1, var2 0, 0 0, 1 1, 3 -9, 0 0, 2 1, 7 I try to specify the dtype as I import: dtype_dict = {'var1':'bool','var2':'int'} nan_dict = {'var1':[-9]} foo = pd.read_csv('test.csv',dtype=dtype_dict, na_values=nan_dict) I get