Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pandas.read_csv() interprets TRUE as boolean, I need a string

I'm reading stock tickers from comma delimited file using pandas.read_csv(). One of the tickers is TRUE, so pandas reader interprets it as a boolean, and fails, since it needs a string to retrieve prices. How can I force TRUE into a string?

like image 475
Ilya Shutman Avatar asked Sep 16 '25 12:09

Ilya Shutman


1 Answers

Specify the dtype of the desired column in the read_csv method call:

pd.read_csv('weirdly_formatted_csv.csv', dtype={'weird_column': str}) 
like image 111
Oliver Sherouse Avatar answered Sep 18 '25 08:09

Oliver Sherouse