@@ -3981,18 +3981,14 @@ def to_timestamp(self, freq=None, how='start', axis=0, copy=True):
3981
3981
if copy :
3982
3982
new_data = new_data .copy ()
3983
3983
3984
- new_index , new_columns = self .index , self .columns
3985
-
3986
3984
if axis == 0 :
3987
- new_index = self .index .to_timestamp (freq = freq , how = how )
3985
+ new_data . set_axis ( 1 , self .index .to_timestamp (freq = freq , how = how ) )
3988
3986
elif axis == 1 :
3989
- new_columns = self .columns .to_timestamp (freq = freq , how = how )
3987
+ new_data . set_axis ( 0 , self .columns .to_timestamp (freq = freq , how = how ) )
3990
3988
else :
3991
3989
raise ValueError ('Axis must be 0 or 1. Got %s' % str (axis ))
3992
3990
3993
- axes = [new_columns , new_index ]
3994
- new_data = BlockManager (new_data .blocks , axes )
3995
- return DataFrame (new_data , index = new_index , columns = new_columns )
3991
+ return DataFrame (new_data )
3996
3992
3997
3993
def to_period (self , freq = None , axis = 0 , copy = True ):
3998
3994
"""
@@ -4015,23 +4011,18 @@ def to_period(self, freq=None, axis=0, copy=True):
4015
4011
if copy :
4016
4012
new_data = new_data .copy ()
4017
4013
4018
- new_index , new_columns = self .index , self .columns
4019
-
4020
4014
if axis == 0 :
4021
4015
if freq is None :
4022
4016
freq = self .index .freqstr or self .index .inferred_freq
4023
- new_index = self .index .to_period (freq = freq )
4017
+ new_data . set_axis ( 1 , self .index .to_period (freq = freq ) )
4024
4018
elif axis == 1 :
4025
4019
if freq is None :
4026
4020
freq = self .columns .freqstr or self .columns .inferred_freq
4027
- new_columns = self .columns .to_period (freq = freq )
4021
+ new_data . set_axis ( 0 , self .columns .to_period (freq = freq ) )
4028
4022
else :
4029
4023
raise ValueError ('Axis must be 0 or 1. Got %s' % str (axis ))
4030
4024
4031
- axes = [new_columns , new_index ]
4032
- new_data = BlockManager (new_data .blocks , axes )
4033
-
4034
- return DataFrame (new_data , index = new_index , columns = new_columns )
4025
+ return DataFrame (new_data )
4035
4026
4036
4027
#----------------------------------------------------------------------
4037
4028
# Deprecated stuff
0 commit comments