I have a pandas.DataFrame that I wish to export to a CSV file. However, pandas seems to write some of the values as float instead of int
pandas.DataFrame
float
int
You can use astype() to specify data type for each column
For example:
import pandas df = pandas.DataFrame(data, columns=['a','b','c','d'], index=['x','y','z']) df = df.astype({"a": int, "b": complex, "c" : float, "d" : int})