Pandsa to Excel conversion issue
EK Esawi
ekesawi at yahoo.com
Tue Jun 1 16:21:15 EDT 2021
Hi All--
I am using Pandas to read an excel file which is very "dirty" and needs cleaning. I read the file via pandas and did not setup dtypes or converters hoping i can do so later.. When i run my code, most columns did come out as strings but i cannot convert them to float or integer using astype or pandas.to numeric method. Every time i tried, i get the same error listed below
Here is my code
import pandas as pd
import numpy as np
MyFile='C:/Users/Temp.xlsx'
df=pd.read_excel(io=MyFile, nrows=100)
The error message i get when i tried to convert a string like '22.3' via astype or pd.to_numeric is below
Unable to parse string "22." at position 0
Thanks in advance
EK
More information about the Python-list
mailing list