Closed
Description
Code Sample, a copy-pastable example if possible
Some inconsistencies there.
# OK: specifying int dtype with float value coerces to int (same as numpy)
pd.Series([1, 2, 3.5], dtype=int)
#0 1
#1 2
#2 3
# dtype: int64
# OK
pd.Index(np.array([1, 2, 3.5], dtype=int))
# Int64Index([1, 2, 3], dtype='int64')
# NG: If list is given, dtype is ignored
pd.Index([1, 2, 3.5], dtype=int)
# Float64Index([1.0, 2.0, 3.5], dtype='float64')
Expected Output
- All list-like input should be handled by a consistent logic.
- If
dtype
is specified, the result must be the specifieddtype
. Otherwise raise.- To do this, merge base
Index
creation andSeries
sanitizing logic to use samendarray
dtype
handling.
- To do this, merge base
output of pd.show_versions()
Current master.