@@ -3692,39 +3692,43 @@ def as_blocks(self, copy=True):
3692
3692
Convert the frame to a dict of dtype -> Constructor Types that each has
3693
3693
a homogeneous dtype.
3694
3694
3695
+ .. deprecated:: 0.21.0
3696
+
3695
3697
NOTE: the dtypes of the blocks WILL BE PRESERVED HERE (unlike in
3696
3698
as_matrix)
3697
3699
3698
3700
Parameters
3699
3701
----------
3700
3702
copy : boolean, default True
3701
3703
3702
- .. versionadded: 0.16.1
3703
-
3704
3704
Returns
3705
3705
-------
3706
3706
values : a dict of dtype -> Constructor Types
3707
3707
"""
3708
- self ._consolidate_inplace ()
3709
-
3710
- bd = {}
3711
- for b in self ._data .blocks :
3712
- bd .setdefault (str (b .dtype ), []).append (b )
3713
-
3714
- result = {}
3715
- for dtype , blocks in bd .items ():
3716
- # Must combine even after consolidation, because there may be
3717
- # sparse items which are never consolidated into one block.
3718
- combined = self ._data .combine (blocks , copy = copy )
3719
- result [dtype ] = self ._constructor (combined ).__finalize__ (self )
3720
-
3721
- return result
3708
+ warnings .warn ("as_blocks is deprecated and will "
3709
+ "be removed in a future version" ,
3710
+ FutureWarning , stacklevel = 2 )
3711
+ return self ._to_dict_of_blocks (copy = copy )
3722
3712
3723
3713
@property
3724
3714
def blocks (self ):
3725
- """Internal property, property synonym for as_blocks()"""
3715
+ """
3716
+ Internal property, property synonym for as_blocks()
3717
+
3718
+ .. deprecated:: 0.21.0
3719
+ """
3726
3720
return self .as_blocks ()
3727
3721
3722
+ def _to_dict_of_blocks (self , copy = True ):
3723
+ """
3724
+ Return a dict of dtype -> Constructor Types that
3725
+ each is a homogeneous dtype.
3726
+
3727
+ Internal ONLY
3728
+ """
3729
+ return {k : self ._constructor (v ).__finalize__ (self )
3730
+ for k , v , in self ._data .to_dict (copy = copy ).items ()}
3731
+
3728
3732
@deprecate_kwarg (old_arg_name = 'raise_on_error' , new_arg_name = 'errors' ,
3729
3733
mapping = {True : 'raise' , False : 'ignore' })
3730
3734
def astype (self , dtype , copy = True , errors = 'raise' , ** kwargs ):
@@ -3931,13 +3935,12 @@ def convert_objects(self, convert_dates=True, convert_numeric=False,
3931
3935
-------
3932
3936
converted : same as input object
3933
3937
"""
3934
- from warnings import warn
3935
3938
msg = ("convert_objects is deprecated. To re-infer data dtypes for "
3936
3939
"object columns, use {klass}.infer_objects()\n For all "
3937
3940
"other conversions use the data-type specific converters "
3938
3941
"pd.to_datetime, pd.to_timedelta and pd.to_numeric."
3939
3942
).format (klass = self .__class__ .__name__ )
3940
- warn (msg , FutureWarning , stacklevel = 2 )
3943
+ warnings . warn (msg , FutureWarning , stacklevel = 2 )
3941
3944
3942
3945
return self ._constructor (
3943
3946
self ._data .convert (convert_dates = convert_dates ,
@@ -4310,9 +4313,9 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None,
4310
4313
raise AssertionError ("'to_replace' must be 'None' if 'regex' is "
4311
4314
"not a bool" )
4312
4315
if axis is not None :
4313
- from warnings import warn
4314
- warn ( 'the "axis" argument is deprecated and will be removed in'
4315
- 'v0.13; this argument has no effect' )
4316
+ warnings . warn ( 'the "axis" argument is deprecated '
4317
+ ' and will be removed in'
4318
+ 'v0.13; this argument has no effect' )
4316
4319
4317
4320
self ._consolidate_inplace ()
4318
4321
0 commit comments