From ddd8a86bf92e36e71c1851864682e36908a5192f Mon Sep 17 00:00:00 2001 From: pixelsoup42 Date: Sat, 14 Oct 2023 14:10:37 +0200 Subject: [PATCH] add sort by appearance --- .../cardano_account_pandas_dumper.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cardano_account_pandas_dumper/cardano_account_pandas_dumper.py b/src/cardano_account_pandas_dumper/cardano_account_pandas_dumper.py index 98b2aff..faa275d 100644 --- a/src/cardano_account_pandas_dumper/cardano_account_pandas_dumper.py +++ b/src/cardano_account_pandas_dumper/cardano_account_pandas_dumper.py @@ -594,7 +594,7 @@ def make_transaction_frame( def _plot_title(self): return f"Asset balances in wallet until block {self.data.to_block}." - def plot_balance(self, order:str="alpha"): + def plot_balance(self, order:str="appearance"): """ Create a Matplotlib plot with the asset balance over time.""" balance = self.make_balance_frame(with_total=False,raw_values=True).cumsum() if order=="alpha": @@ -606,7 +606,13 @@ def plot_balance(self, order:str="alpha"): key=lambda i: [self.asset_names.get(x, x) for x in i], ) elif order=="appearance": - pass + balance.sort_index( + axis=1, + level=0, + sort_remaining=True, + inplace=True, + key=lambda i: [balance[x].first_valid_index() for x in i], + ) else: raise ValueError(f"Unkown ordering: {order}") fig,ax=pyplot.subplots(len(balance.columns),2,