@@ -306,12 +306,12 @@ def _clean(data):
306
306
# print(data.isnull().sum())
307
307
308
308
# if low is not the lowest, set it to nan
309
- data [ 'low' ]. loc [
310
- data [ 'low' ] > data [[ 'open' , 'high' , 'close' ]]. min ( 1 )] = np .nan
309
+ data . loc [ data [ 'low' ] > data [[ 'open' , 'high' , 'close' ]]. min ( 1 ),
310
+ 'low' ] = np .nan
311
311
312
312
# if high is not the highest, set it to nan
313
- data [ 'high' ]. loc [
314
- data [ 'high' ] < data [[ 'open' , 'high' , 'close' ]]. max ( 1 ) ] = np .nan
313
+ data . loc [ data [ 'high' ] < data [[ 'open' , 'high' , 'close' ]]. max ( 1 ),
314
+ 'high' ] = np .nan
315
315
316
316
# print(data)
317
317
# print(data.isnull().sum())
@@ -959,7 +959,8 @@ def _add_cash_column(self, cash_key, grace_period):
959
959
# be misaligned (e.g., with tz-aware timestamps)
960
960
cash_returns_per_period .name = self .cash_key
961
961
original_returns_index = self .returns .index
962
- tmp = pd .concat ([self .returns , cash_returns_per_period ], axis = 1 )
962
+ tmp = pd .concat (
963
+ [self .returns , cash_returns_per_period ], sort = True , axis = 1 )
963
964
tmp [cash_key ] = tmp [cash_key ].ffill ()
964
965
self .returns = tmp .loc [original_returns_index ]
965
966
@@ -1082,9 +1083,8 @@ def _downsample(self, interval):
1082
1083
1083
1084
# we nan-out the first non-nan element of every col
1084
1085
for col in self .returns .columns [:- 1 ]:
1085
- self .returns [col ].loc [
1086
- (~ (self .returns [col ].isnull ())).idxmax ()
1087
- ] = np .nan
1086
+ self .returns .loc [
1087
+ (~ (self .returns [col ].isnull ())).idxmax (), col ] = np .nan
1088
1088
1089
1089
# and we drop the first row, which is mostly NaNs anyway
1090
1090
self .returns = self .returns .iloc [1 :]
@@ -1107,9 +1107,8 @@ def _downsample(self, interval):
1107
1107
1108
1108
# we nan-out the first non-nan element of every col
1109
1109
for col in self .volumes .columns :
1110
- self .volumes [col ].loc [
1111
- (~ (self .volumes [col ].isnull ())).idxmax ()
1112
- ] = np .nan
1110
+ self .volumes .loc [
1111
+ (~ (self .volumes [col ].isnull ())).idxmax (), col ] = np .nan
1113
1112
1114
1113
# and we drop the first row, which is mostly NaNs anyway
1115
1114
self .volumes = self .volumes .iloc [1 :]
@@ -1129,9 +1128,8 @@ def _downsample(self, interval):
1129
1128
1130
1129
# we nan-out the first non-nan element of every col
1131
1130
for col in self .prices .columns :
1132
- self .prices [col ].loc [
1133
- (~ (self .prices [col ].isnull ())).idxmax ()
1134
- ] = np .nan
1131
+ self .prices .loc [
1132
+ (~ (self .prices [col ].isnull ())).idxmax (), col ] = np .nan
1135
1133
1136
1134
# and we drop the first row, which is mostly NaNs anyway
1137
1135
self .prices = self .prices .iloc [1 :]
0 commit comments