Skip to content

Commit d7cf251

Browse files
committed
fix some bugs in pandas==0.25.0
1 parent db74748 commit d7cf251

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

pyfolio/capacity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def daily_txns_with_bar_data(transactions, market_data):
3434
transactions.index.name = 'date'
3535
txn_daily = pd.DataFrame(transactions.assign(
3636
amount=abs(transactions.amount)).groupby(
37-
['symbol', pd.TimeGrouper('D')]).sum()['amount'])
37+
['symbol', pd.Grouper(freq='D')]).sum()['amount'])
3838
txn_daily['price'] = market_data.xs('price', level=1).unstack()
3939
txn_daily['volume'] = market_data.xs('volume', level=1).unstack()
4040

pyfolio/round_trips.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,13 @@ def agg_all_long_short(round_trips, col, stats_dict):
7979
.groupby('ones')[col]
8080
.agg(stats_dict)
8181
.T
82-
.rename_axis({1.0: 'All trades'},
83-
axis='columns'))
82+
.rename(columns={1.0: 'All trades'}))
8483
stats_long_short = (round_trips
8584
.groupby('long')[col]
8685
.agg(stats_dict)
8786
.T
88-
.rename_axis({False: 'Short trades',
89-
True: 'Long trades'},
90-
axis='columns'))
87+
.rename(columns={False: 'Short trades',
88+
True: 'Long trades'}))
9189

9290
return stats_all.join(stats_long_short)
9391

pyfolio/tests/test_round_trips.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class RoundTripTestCase(TestCase):
3939
],
4040
columns=['amount', 'price', 'symbol'],
4141
index=dates_intraday[[0, 2]])
42-
.rename_axis('dt', axis='index')
42+
.rename('dt', axis='index')
4343
),
4444
(DataFrame(data=[[2, 10., 'A'],
4545
[2, 20., 'A'],
@@ -53,7 +53,7 @@ class RoundTripTestCase(TestCase):
5353
],
5454
columns=['amount', 'price', 'symbol'],
5555
index=dates_intraday[[0, 4]])
56-
.rename_axis('dt', axis='index')
56+
.rename('dt', axis='index')
5757
),
5858
])
5959
def test_groupby_consecutive(self, transactions, expected):

pyfolio/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,7 @@ def estimate_intraday(returns, positions, transactions, EOD_hour=23):
348348
columns='symbol').replace(np.nan, 0)
349349

350350
# Cumulate transaction amounts each day
351-
txn_val['date'] = txn_val.index.date
352-
txn_val = txn_val.groupby('date').cumsum()
351+
txn_val = txn_val.groupby(txn_val.index.date).cumsum()
353352

354353
# Calculate exposure, then take peak of exposure every day
355354
txn_val['exposure'] = txn_val.abs().sum(axis=1)

0 commit comments

Comments
 (0)