|
119 | 119 | from pandas.core.arrays.categorical import CategoricalAccessor |
120 | 120 | from pandas.core.arrays.sparse import SparseAccessor |
121 | 121 | from pandas.core.construction import ( |
122 | | - create_series_with_explicit_dtype, |
123 | 122 | extract_array, |
124 | | - is_empty_data, |
125 | 123 | sanitize_array, |
126 | 124 | ) |
127 | 125 | from pandas.core.generic import NDFrame |
@@ -389,18 +387,6 @@ def __init__( |
389 | 387 |
|
390 | 388 | name = ibase.maybe_extract_name(name, data, type(self)) |
391 | 389 |
|
392 | | - if is_empty_data(data) and dtype is None: |
393 | | - # gh-17261 |
394 | | - warnings.warn( |
395 | | - "The default dtype for empty Series will be 'object' instead " |
396 | | - "of 'float64' in a future version. Specify a dtype explicitly " |
397 | | - "to silence this warning.", |
398 | | - FutureWarning, |
399 | | - stacklevel=find_stack_level(), |
400 | | - ) |
401 | | - # uncomment the line below when removing the FutureWarning |
402 | | - # dtype = np.dtype(object) |
403 | | - |
404 | 390 | if index is not None: |
405 | 391 | index = ensure_index(index) |
406 | 392 |
|
@@ -458,6 +444,9 @@ def __init__( |
458 | 444 | pass |
459 | 445 | else: |
460 | 446 | data = com.maybe_iterable_to_list(data) |
| 447 | + if is_list_like(data) and not len(data) and dtype is None: |
| 448 | + # GH 29405: Pre-2.0, this defaulted to float. |
| 449 | + dtype = np.dtype(object) |
461 | 450 |
|
462 | 451 | if index is None: |
463 | 452 | if not is_list_like(data): |
@@ -531,15 +520,10 @@ def _init_dict( |
531 | 520 |
|
532 | 521 | # Input is now list-like, so rely on "standard" construction: |
533 | 522 |
|
534 | | - # TODO: passing np.float64 to not break anything yet. See GH-17261 |
535 | | - s = create_series_with_explicit_dtype( |
536 | | - # error: Argument "index" to "create_series_with_explicit_dtype" has |
537 | | - # incompatible type "Tuple[Any, ...]"; expected "Union[ExtensionArray, |
538 | | - # ndarray, Index, None]" |
| 523 | + s = self._constructor( |
539 | 524 | values, |
540 | | - index=keys, # type: ignore[arg-type] |
| 525 | + index=keys, |
541 | 526 | dtype=dtype, |
542 | | - dtype_if_empty=np.float64, |
543 | 527 | ) |
544 | 528 |
|
545 | 529 | # Now we just make sure the order is respected, if any |
|
0 commit comments