1

Each row in my data frame has a mix of floats and integers. How could I create a list with all the values in the row that preserves the data types of each value?

I've attempted to convert it into a numpy.recarray but that messes with the data types.

Using dataframe.values.tolist() also messes with the data types.

I tried to use itertuples because the Pandas docs said to use that instead of iterrows if I wanted to preserve dtypes across the row but it still messes with my data types.

Ex: 1 row in my dataframe has values like [0, 0.0, 0, 0.0, 1, 0.0, 0.2, 0.2, 0.0, 0.0, 1, 1, 1, 1, 1, 1, 0] and I just want to keep it that way.

Any simple methods?

4

0 回答 0