Skip to content

Commit c7b565b

Browse files
committed
REF: Fix pandas deprecation warning
> FutureWarning: casting datetime64[ns] values to int64 > with .astype(...) is deprecated and will raise in a future > version. Use .view(...) instead.
1 parent ae11c90 commit c7b565b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

backtesting/_plotting.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ def _weighted_returns(s, trades=trades):
138138
return ((df['Size'].abs() * df['ReturnPct']) / df['Size'].abs().sum()).sum()
139139

140140
def _group_trades(column):
141-
def f(s, new_index=df.index.astype(np.int64), bars=trades[column]):
141+
def f(s, new_index=pd.Index(df.index.view(int)), bars=trades[column]):
142142
if s.size:
143143
# Via int64 because on pandas recently broken datetime
144-
mean_time = int(bars.loc[s.index].view('i8').mean())
144+
mean_time = int(bars.loc[s.index].view(int).mean())
145145
new_bar_idx = new_index.get_loc(mean_time, method='nearest')
146146
return new_bar_idx
147147
return f

0 commit comments

Comments
 (0)