Closed
Description
Index.__new__
does inference on numeric data more aggressively than Series.__new__
. It would be nice if these behaviors matched. (xref #40451 also about differenced between Series vs Index inference, though in that case Series is more aggressive about inference)
data = np.array([np.nan, np.nan, 2.0], dtype=object)
>>> pd.Series(data).dtype
dtype('O')
>>> pd.Index(data).dtype
dtype('float64')
>>> pd.array(data).dtype
Float64Dtype()
(if we passed data[:-1] to pd.array we'd get back a PandasArray[object] bc it passes skipna=True to lib.infer_dtype
)
Changing the Series behavior to match Index breaks 207 tests (140 of which are for the str accessor; i expect some others are false-positives), so this would be a non-trivial API change.