Skip to content

Commit

Permalink
Finished the last two changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
noubre committed Dec 7, 2022
1 parent de80774 commit 629850f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
7 changes: 5 additions & 2 deletions openbb_terminal/cryptocurrency/onchain/blockchain_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ def get_btc_single_block(blockhash: str) -> pd.DataFrame:

data = _blockchain_data_api_make_request(f"rawblock/{blockhash}?format=json")

df = pd.json_normalize(data)
if data:

return df
df = pd.json_normalize(data)
return df

return pd.DataFrame()

50 changes: 24 additions & 26 deletions openbb_terminal/cryptocurrency/onchain/blockchain_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,35 +149,33 @@ def display_btc_single_block(
"""

df = blockchain_model.get_btc_single_block(blockhash)
df.rename(index={0: "Value"}, inplace=True)
df.index.name = "Metric"
df_data = df.copy()

df_essentials = df[[
"hash",
"ver",
"prev_block",
"mrkl_root",
"bits",
"next_block",
"fee",
"nonce",
"n_tx",
"size",
"block_index",
"main_chain",
"height",
"weight",
]]

df_flipped = df_essentials.transpose()

if df_flipped.empty:
console.print("No data found.")
else:
if not df.empty:
df.rename(index={0: "Value"}, inplace=True)
df_data = df.copy()

df_essentials = df[[
"hash",
"ver",
"prev_block",
"mrkl_root",
"bits",
"next_block",
"fee",
"nonce",
"n_tx",
"size",
"block_index",
"main_chain",
"height",
"weight",
]]

df_flipped = df_essentials.transpose()

print_rich_table(
df_flipped,
show_index=True,
index_name="Metric",
title=f"Block {int(df['height'])}",
)

Expand Down

0 comments on commit 629850f

Please sign in to comment.