Skip to content

Instantly share code, notes, and snippets.

@RaekwonIII
Created February 22, 2023 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RaekwonIII/f92c8c4a3de8220752f1ac4c322e1311 to your computer and use it in GitHub Desktop.
Save RaekwonIII/f92c8c4a3de8220752f1ac4c322e1311 to your computer and use it in GitHub Desktop.
Simple Python script that ingests and analyzes parquet files of Uniswap "Swap" events, from Parquet files, aggregates them by day, and plots a bar chart of the total daily amount of Swaps
import pandas as pd
from pathlib import Path
import matplotlib.pyplot as plt
df = pd.concat(map(lambda parquet_file: pd.read_parquet(parquet_file, engine="pyarrow"), Path(r'./').rglob('**/pool_event_Swap.parquet')), ignore_index=True)
df['datetime'] = pd.to_datetime(df['timestamp'])
sumDf = df.groupby(df.datetime.dt.date)["contractAddress"].count()
sumDf.plot(kind = 'bar',
x = 0,
y = 1,
color = 'blue',
title='Total Daily Swaps on Uniswap',
)
# show the plot
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment