Gizmo
Gizmo

Reputation: 941

Converting the dtype of columns in pandas without column names

I am working with data imported from a huge CSV. Pandas changed some columns to float, so now the numbers in these columns get displayed as floating points! However, I need them to be integers. I found some solutions, but all used the column names to change the dtypes.

Is there a way to change the data type for example for the first one thousand columns without addressing them separately by their names?

Upvotes: 0

Views: 1072

Answers (1)

MaxU - stand with Ukraine
MaxU - stand with Ukraine

Reputation: 210842

df.iloc[:, :1000] = df.iloc[:, :1000].astype(int)

Upvotes: 1

Related Questions