I have a CSV file that looks as follows:
name,id,weight
a,12345,196.5
b,83748,
,83748,200.0
c, ,155.5
Note, there are several missing values indicated by a single space.
When I load this CSV file into a Pandas DataFrame and check the data types using dtypes , it says that every column is of type "object". Even after I convert the spaces to NaN, it still says everything is an "object".
How do I get the data types to be read in correctly, despite the spaces? Could this possibly be an issue with the Anaconda platform?
调用read_csv()
,请确保使用na_values=' '
(或您实际使用的NaN值read_csv()
进行调用。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.