Importing Numbers using DataFrame

Viewed 23

I'm trying to import numbers from a xlsx file using pandas DataFrame. But I'm getting numbers in a slightly different format,

let's say the number is: 9582*****4

the number i get using this code is 9582*****4.0

df=pd.read_excel("Contacts.xlsx") for i in range(len(df)): print(df.iloc[i,0])

It was working just fine till last night.

1 Answers

i guess you need to change the data type from float to int

df=pd.read_excel("Contacts.xlsx")

df = df.astype(int) # for all columns

type df = df.astype({"Column_name": int}) # for specific column

for i in range(len(df)):
    print(df.iloc[i,0])
Related