@@ -385,18 +385,7 @@ def __init__(
385
385
dtype : Dtype | None = None ,
386
386
name = None ,
387
387
copy : bool | None = None ,
388
- fastpath : bool | lib .NoDefault = lib .no_default ,
389
388
) -> None :
390
- if fastpath is not lib .no_default :
391
- warnings .warn (
392
- "The 'fastpath' keyword in pd.Series is deprecated and will "
393
- "be removed in a future version." ,
394
- DeprecationWarning ,
395
- stacklevel = find_stack_level (),
396
- )
397
- else :
398
- fastpath = False
399
-
400
389
allow_mgr = False
401
390
if (
402
391
isinstance (data , SingleBlockManager )
@@ -417,11 +406,7 @@ def __init__(
417
406
data = data .copy (deep = False )
418
407
# GH#33357 called with just the SingleBlockManager
419
408
NDFrame .__init__ (self , data )
420
- if fastpath :
421
- # e.g. from _box_col_values, skip validation of name
422
- object .__setattr__ (self , "_name" , name )
423
- else :
424
- self .name = name
409
+ self .name = name
425
410
return
426
411
427
412
is_pandas_object = isinstance (data , (Series , Index , ExtensionArray ))
@@ -435,31 +420,6 @@ def __init__(
435
420
if copy is None :
436
421
copy = False
437
422
438
- # we are called internally, so short-circuit
439
- if fastpath :
440
- # data is a ndarray, index is defined
441
- if not isinstance (data , SingleBlockManager ):
442
- data = SingleBlockManager .from_array (data , index )
443
- allow_mgr = True
444
- elif using_copy_on_write () and not copy :
445
- data = data .copy (deep = False )
446
-
447
- if not allow_mgr :
448
- warnings .warn (
449
- f"Passing a { type (data ).__name__ } to { type (self ).__name__ } "
450
- "is deprecated and will raise in a future version. "
451
- "Use public APIs instead." ,
452
- DeprecationWarning ,
453
- stacklevel = 2 ,
454
- )
455
-
456
- if copy :
457
- data = data .copy ()
458
- # skips validation of the name
459
- object .__setattr__ (self , "_name" , name )
460
- NDFrame .__init__ (self , data )
461
- return
462
-
463
423
if isinstance (data , SingleBlockManager ) and using_copy_on_write () and not copy :
464
424
data = data .copy (deep = False )
465
425
@@ -851,104 +811,12 @@ def _references(self) -> BlockValuesRefs:
851
811
def array (self ) -> ExtensionArray :
852
812
return self ._mgr .array_values ()
853
813
854
- # ops
855
- def ravel (self , order : str = "C" ) -> ArrayLike :
856
- """
857
- Return the flattened underlying data as an ndarray or ExtensionArray.
858
-
859
- .. deprecated:: 2.2.0
860
- Series.ravel is deprecated. The underlying array is already 1D, so
861
- ravel is not necessary. Use :meth:`to_numpy` for conversion to a numpy
862
- array instead.
863
-
864
- Returns
865
- -------
866
- numpy.ndarray or ExtensionArray
867
- Flattened data of the Series.
868
-
869
- See Also
870
- --------
871
- numpy.ndarray.ravel : Return a flattened array.
872
-
873
- Examples
874
- --------
875
- >>> s = pd.Series([1, 2, 3])
876
- >>> s.ravel() # doctest: +SKIP
877
- array([1, 2, 3])
878
- """
879
- warnings .warn (
880
- "Series.ravel is deprecated. The underlying array is already 1D, so "
881
- "ravel is not necessary. Use `to_numpy()` for conversion to a numpy "
882
- "array instead." ,
883
- FutureWarning ,
884
- stacklevel = 2 ,
885
- )
886
- arr = self ._values .ravel (order = order )
887
- if isinstance (arr , np .ndarray ) and using_copy_on_write ():
888
- arr .flags .writeable = False
889
- return arr
890
-
891
814
def __len__ (self ) -> int :
892
815
"""
893
816
Return the length of the Series.
894
817
"""
895
818
return len (self ._mgr )
896
819
897
- def view (self , dtype : Dtype | None = None ) -> Series :
898
- """
899
- Create a new view of the Series.
900
-
901
- .. deprecated:: 2.2.0
902
- ``Series.view`` is deprecated and will be removed in a future version.
903
- Use :meth:`Series.astype` as an alternative to change the dtype.
904
-
905
- This function will return a new Series with a view of the same
906
- underlying values in memory, optionally reinterpreted with a new data
907
- type. The new data type must preserve the same size in bytes as to not
908
- cause index misalignment.
909
-
910
- Parameters
911
- ----------
912
- dtype : data type
913
- Data type object or one of their string representations.
914
-
915
- Returns
916
- -------
917
- Series
918
- A new Series object as a view of the same data in memory.
919
-
920
- See Also
921
- --------
922
- numpy.ndarray.view : Equivalent numpy function to create a new view of
923
- the same data in memory.
924
-
925
- Notes
926
- -----
927
- Series are instantiated with ``dtype=float64`` by default. While
928
- ``numpy.ndarray.view()`` will return a view with the same data type as
929
- the original array, ``Series.view()`` (without specified dtype)
930
- will try using ``float64`` and may fail if the original data type size
931
- in bytes is not the same.
932
-
933
- Examples
934
- --------
935
- Use ``astype`` to change the dtype instead.
936
- """
937
- warnings .warn (
938
- "Series.view is deprecated and will be removed in a future version. "
939
- "Use ``astype`` as an alternative to change the dtype." ,
940
- FutureWarning ,
941
- stacklevel = 2 ,
942
- )
943
- # self.array instead of self._values so we piggyback on NumpyExtensionArray
944
- # implementation
945
- res_values = self .array .view (dtype )
946
- res_ser = self ._constructor (res_values , index = self .index , copy = False )
947
- if isinstance (res_ser ._mgr , SingleBlockManager ):
948
- blk = res_ser ._mgr ._block
949
- blk .refs .add_reference (blk )
950
- return res_ser .__finalize__ (self , method = "view" )
951
-
952
820
# ----------------------------------------------------------------------
953
821
# NDArray Compat
954
822
def __array__ (self , dtype : npt .DTypeLike | None = None ) -> np .ndarray :
0 commit comments