34 lines
945 B
Python
34 lines
945 B
Python
import pandas as pd
|
|
import matplotlib.pyplot as plt
|
|
from matplotlib.table import Table
|
|
|
|
# Simulating the cache as a DataFrame
|
|
data = {
|
|
'key': ['BTC/USD_2h_binance', 'ETH/USD_1h_coinbase'],
|
|
'data': ['{"open": 50000, "close": 50500}', '{"open": 1800, "close": 1825}']
|
|
}
|
|
cache_df = pd.DataFrame(data)
|
|
|
|
|
|
# Visualization function
|
|
def visualize_cache(df):
|
|
fig, ax = plt.subplots(figsize=(6, 3))
|
|
ax.set_axis_off()
|
|
tb = Table(ax, bbox=[0, 0, 1, 1])
|
|
|
|
# Adding column headers
|
|
for i, column in enumerate(df.columns):
|
|
tb.add_cell(0, i, width=0.4, height=0.3, text=column, loc='center', facecolor='lightgrey')
|
|
|
|
# Adding rows and cells
|
|
for i in range(len(df)):
|
|
for j, value in enumerate(df.iloc[i]):
|
|
tb.add_cell(i + 1, j, width=0.4, height=0.3, text=value, loc='center', facecolor='white')
|
|
|
|
ax.add_table(tb)
|
|
plt.title("Visualizing Cache Data")
|
|
plt.show()
|
|
|
|
|
|
visualize_cache(cache_df)
|