としてリストされている要素を内部に保持しながら、配列のデータ型を(または何でも)numpy
固定したままにするための推奨される方法はありますか?int
int64
numpy.NaN
In particular, I am converting an in-house data structure to a Pandas DataFrame. In our structure, we have integer-type columns that still have NaN's (but the dtype of the column is int). It seems to recast everything as a float if we make this a DataFrame, but we'd really like to be int
.
Thoughts?
Things tried:
I tried using the from_records()
function under pandas.DataFrame, with coerce_float=False
and this did not help. I also tried using NumPy masked arrays, with NaN fill_value, which also did not work. All of these caused the column data type to become a float.