Skip to content

Commit

Permalink
add rewards column
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelsoup42 committed Sep 30, 2023
1 parent f58e0aa commit f074274
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/cardano_account_pandas_dumper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def main():
reporter.make_transaction_frame(
transactions,
detail_level=args.detail_level,
with_rewards=not args.no_rewards,
).replace(np.float64(0), pd.NA).to_csv(args.csv_output, index=False)
except OSError as exception:
warnings.warn(f"Failed to write CSV file: {exception}")
Expand All @@ -206,6 +207,7 @@ def main():
reporter.make_transaction_frame(
transactions,
detail_level=args.detail_level,
with_rewards=not args.no_rewards,
text_cleaner=lambda x: ILLEGAL_CHARACTERS_RE.sub(
lambda y: "".join(
["\\x0" + hex(ord(y.group(0))).removeprefix("0x")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,17 +451,23 @@ def make_transaction_frame(
self,
transactions: pd.Series,
detail_level: int,
text_cleaner: Callable = lambda x: x,
with_rewards: bool,
with_tx_hash: bool = True,
with_tx_message: bool = True,
with_total: bool = True,
text_cleaner: Callable = lambda x: x,
) -> pd.DataFrame:
"""Build a transaction spreadsheet."""

columns = [transactions.rename("timestamp").map(self._extract_timestamp)]
total: List[Any] = [columns[0].max() + self.TRANSACTION_OFFSET]
if with_tx_hash:
columns.append(transactions.rename("hash").map(lambda x: x.hash))
total.append("" if (with_tx_message or with_rewards) else "Total")
if with_rewards:
columns.append(
transactions.rename("reward").map(lambda x: bool(x.reward_amount))
)
total.append("" if with_tx_message else "Total")
if with_tx_message:
columns.append(
Expand Down

0 comments on commit f074274

Please sign in to comment.