DataFrame populated with the letter "n" when no data passed and dtype is specified as str · Issue #9428 · pandas-dev/pandas (original) (raw)
This is discussed on Stack Overflow here.
When constructing a DataFrame with the dtype
as str
but not passing in any data (just an index), the resulting DataFrame is filled with the letter n
:
In [61]: pd.DataFrame(index=range(2), columns=[0], dtype=str) Out[61]: 0 0 n 1 n
This is contrary to the behaviour of Series when no data is passed in:
In [62]: pd.Series(index=range(2), dtype=str) Out[62]: 0 NaN 1 NaN dtype: object
It would be logical for the DataFrame to be populated with NaN
in this instance too.