Exporting to Disk#
Once you've done your work with subgrounds
, it might be time to export your CSV to another platform. This is simply handled by pandas
via pandas.DataFrame.to_csv()
.
Click for Interactive Documentation
Clicking this button will enable editing and execution of the code-blocks on this page. Learn more here.
Example#
In this example, we'll export some curve data for further analysis.
from subgrounds import Subgrounds
sg = Subgrounds()
aave_v2 = sg.load_subgraph(
"https://api.thegraph.com/subgraphs/name/messari/aave-v2-ethereum")
df = sg.query_df(aave_v2.Query.marketDailySnapshots(first=1000))
df.head() # show the first 5 rows
df.to_csv("my_data.csv")
Tip
There are several other formats that can be exported described here.
You can also easily load CSV files back into a pandas.DataFrame
.
import pandas as pd
df2 = pd.read_csv("my_data.csv")
df2.head()