pull/286/head
Tim Pechersky 2021-10-07 18:44:21 +02:00
rodzic 9fc44de4b6
commit 7c4b1625f3
2 zmienionych plików z 792 dodań i 193 usunięć

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@ -29,195 +29,29 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"checkpoint = pd.read_sql_query(\"SELECT * FROM checkpoint\", conTXs)\n",
"mints = pd.read_sql_query(\"SELECT * FROM mints\", conTXs)\n",
"nfts = pd.read_sql_query(\"SELECT * FROM nfts\", conTXs)\n",
"transfers = pd.read_sql_query(\"SELECT * FROM transfers\", conTXs)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" sql\n",
"0 CREATE TABLE nfts\\n (\\n address TEXT...\n",
"1 CREATE TABLE checkpoint\\n (\\n event_...\n",
"2 CREATE TABLE mints\\n (\\n event_id TE...\n",
"3 CREATE TABLE transfers\\n (\\n event_i...\n",
"4 CREATE TABLE current_owners(\\n nft_address TE...\n",
"5 CREATE TABLE current_market_values(\\n nft_add...\n",
"6 CREATE TABLE market_values_distribution(\\n ad...\n"
]
}
],
"outputs": [],
"source": [
"stolbiki = pd.read_sql_query(\"SELECT sql FROM sqlite_master where type='table'\", conTXs) \n",
"print(stolbiki)"
"num_df = (transfers[[\"transaction_value\", \"timestamp\"]].apply(pd.to_numeric, errors='coerce'))\n",
"num_df[\"timestamp\"] = pd.to_datetime(num_df.timestamp, unit='s', errors='coerce')\n",
"num_df.set_index(\"timestamp\")\n",
"num_df = num_df.resample(\"1440min\", label='right', on='timestamp').sum()\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>event_id</th>\n",
" <th>transaction_hash</th>\n",
" <th>block_number</th>\n",
" <th>nft_address</th>\n",
" <th>token_id</th>\n",
" <th>from_address</th>\n",
" <th>to_address</th>\n",
" <th>transaction_value</th>\n",
" <th>timestamp</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>ce7b6ba0-218f-40c7-8d8c-4e3bfc822a41</td>\n",
" <td>0x804cee46e672b17b477658b99c25c8b75f31553278ad...</td>\n",
" <td>11565099</td>\n",
" <td>0x629A673A8242c2AC4B7B8C5D8735fbeac21A6205</td>\n",
" <td>7287012905433418913509099434869470284131894829...</td>\n",
" <td>0x79A8b5Fcc051c843DFCB753eE38d113675E5367D</td>\n",
" <td>0x433f7e8DeFBbCB5459DDD8C6597493e41550F37f</td>\n",
" <td>0.0</td>\n",
" <td>1609460206</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>c81d8767-a523-410e-9f4a-21a25f8e906f</td>\n",
" <td>0x9b124e219f875fa0bb52d90ba937c5d8373ddc8a2c46...</td>\n",
" <td>11565099</td>\n",
" <td>0x629A673A8242c2AC4B7B8C5D8735fbeac21A6205</td>\n",
" <td>1225542446027558019364995253890488984869511709...</td>\n",
" <td>0x2c338BAf69A57A17E69dB86933310e92f64ab69d</td>\n",
" <td>0x433f7e8DeFBbCB5459DDD8C6597493e41550F37f</td>\n",
" <td>0.0</td>\n",
" <td>1609460206</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>d9494633-61fd-4cd6-bd42-e736e0982956</td>\n",
" <td>0x64a82fe7402d2efd82085a10b6a99d6fcedcac21804e...</td>\n",
" <td>11565044</td>\n",
" <td>0x6Fa769EED284a94A73C15299e1D3719B29Ae2F52</td>\n",
" <td>51060026</td>\n",
" <td>0x9503DE24f4210dA79c5e5BCCD198B2727387a519</td>\n",
" <td>0x8B36486EA2E0b70A505D92d30c31CC3197ba5707</td>\n",
" <td>0.0</td>\n",
" <td>1609459570</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>801c3aae-9b72-4a4b-b40b-1cf93308eeea</td>\n",
" <td>0xe74d08ee2cbe4b6b873258462ec5523999433569df66...</td>\n",
" <td>11565042</td>\n",
" <td>0xB2D6fb1Dc231F97F8cC89467B52F7C4F78484044</td>\n",
" <td>4265098311422702060752376543910232329671779809...</td>\n",
" <td>0x0BF988a6cc20af0CDD6f583aD2Fcf057895888e6</td>\n",
" <td>0x0000000000000000000000000000000000000000</td>\n",
" <td>0.0</td>\n",
" <td>1609459545</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" event_id \\\n",
"0 ce7b6ba0-218f-40c7-8d8c-4e3bfc822a41 \n",
"1 c81d8767-a523-410e-9f4a-21a25f8e906f \n",
"2 d9494633-61fd-4cd6-bd42-e736e0982956 \n",
"3 801c3aae-9b72-4a4b-b40b-1cf93308eeea \n",
"\n",
" transaction_hash block_number \\\n",
"0 0x804cee46e672b17b477658b99c25c8b75f31553278ad... 11565099 \n",
"1 0x9b124e219f875fa0bb52d90ba937c5d8373ddc8a2c46... 11565099 \n",
"2 0x64a82fe7402d2efd82085a10b6a99d6fcedcac21804e... 11565044 \n",
"3 0xe74d08ee2cbe4b6b873258462ec5523999433569df66... 11565042 \n",
"\n",
" nft_address \\\n",
"0 0x629A673A8242c2AC4B7B8C5D8735fbeac21A6205 \n",
"1 0x629A673A8242c2AC4B7B8C5D8735fbeac21A6205 \n",
"2 0x6Fa769EED284a94A73C15299e1D3719B29Ae2F52 \n",
"3 0xB2D6fb1Dc231F97F8cC89467B52F7C4F78484044 \n",
"\n",
" token_id \\\n",
"0 7287012905433418913509099434869470284131894829... \n",
"1 1225542446027558019364995253890488984869511709... \n",
"2 51060026 \n",
"3 4265098311422702060752376543910232329671779809... \n",
"\n",
" from_address \\\n",
"0 0x79A8b5Fcc051c843DFCB753eE38d113675E5367D \n",
"1 0x2c338BAf69A57A17E69dB86933310e92f64ab69d \n",
"2 0x9503DE24f4210dA79c5e5BCCD198B2727387a519 \n",
"3 0x0BF988a6cc20af0CDD6f583aD2Fcf057895888e6 \n",
"\n",
" to_address transaction_value timestamp \n",
"0 0x433f7e8DeFBbCB5459DDD8C6597493e41550F37f 0.0 1609460206 \n",
"1 0x433f7e8DeFBbCB5459DDD8C6597493e41550F37f 0.0 1609460206 \n",
"2 0x8B36486EA2E0b70A505D92d30c31CC3197ba5707 0.0 1609459570 \n",
"3 0x0000000000000000000000000000000000000000 0.0 1609459545 "
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"transfers.head(4)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"num_df = (transfers[[\"transaction_value\", \"timestamp\"]].apply(pd.to_numeric, errors='coerce'))\n",
"\n",
"num_df[\"timestamp\"] = pd.to_datetime(num_df.timestamp, unit='s', errors='coerce')\n",
"num_df.set_index(\"timestamp\")\n",
"num_df = num_df.resample(\"1440min\", label='right', on='timestamp').sum()\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
@ -225,7 +59,7 @@
"Text(0.5, 1.0, 'NFT transfers value over time')"
]
},
"execution_count": 10,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
},
@ -252,7 +86,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 7,
"metadata": {},
"outputs": [
{
@ -269,7 +103,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@ -278,7 +112,7 @@
},
{
"cell_type": "code",
"execution_count": 140,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
@ -290,7 +124,7 @@
},
{
"cell_type": "code",
"execution_count": 141,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
@ -301,7 +135,7 @@
},
{
"cell_type": "code",
"execution_count": 142,
"execution_count": 11,
"metadata": {},
"outputs": [
{
@ -347,7 +181,7 @@
},
{
"cell_type": "code",
"execution_count": 143,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
@ -357,7 +191,7 @@
},
{
"cell_type": "code",
"execution_count": 144,
"execution_count": 13,
"metadata": {},
"outputs": [
{
@ -403,7 +237,7 @@
},
{
"cell_type": "code",
"execution_count": 145,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
@ -413,7 +247,7 @@
},
{
"cell_type": "code",
"execution_count": 133,
"execution_count": 15,
"metadata": {},
"outputs": [
{
@ -468,7 +302,7 @@
"0xcDA72070E455bb31C7690a170224Ce43623d0B6f 76645.0 36116.0"
]
},
"execution_count": 133,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
@ -491,7 +325,7 @@
},
{
"cell_type": "code",
"execution_count": 134,
"execution_count": 16,
"metadata": {},
"outputs": [
{
@ -540,7 +374,7 @@
"0x327305A797d92a39cEe1a225D7E2A1cC42B1a8fA NaN 106620.0"
]
},
"execution_count": 134,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
@ -562,7 +396,7 @@
},
{
"cell_type": "code",
"execution_count": 136,
"execution_count": 17,
"metadata": {},
"outputs": [
{
@ -613,7 +447,7 @@
},
{
"cell_type": "code",
"execution_count": 137,
"execution_count": 18,
"metadata": {},
"outputs": [
{
@ -668,7 +502,7 @@
"0xcDA72070E455bb31C7690a170224Ce43623d0B6f 76645.0 36116.0"
]
},
"execution_count": 137,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
@ -692,7 +526,7 @@
},
{
"cell_type": "code",
"execution_count": 138,
"execution_count": 19,
"metadata": {},
"outputs": [
{
@ -741,7 +575,7 @@
"0xb1690C08E213a35Ed9bAb7B318DE14420FB57d8C 14124.0 23128.0"
]
},
"execution_count": 138,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@ -761,6 +595,121 @@
"[0xb1690C08E213a35Ed9bAb7B318DE14420FB57d8C](https://etherscan.io/address/0xb1690C08E213a35Ed9bAb7B318DE14420FB57d8C) / not a contract! / info: `CryptoKitties: Sales Auction `\n"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"#transfers not transactions\n",
"transactions_per_nft = transfers[\"nft_address\"].groupby(transfers[\"nft_address\"]).size()\n"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 0.000000e+00\n",
"1 0.000000e+00\n",
"2 0.000000e+00\n",
"3 0.000000e+00\n",
"4 0.000000e+00\n",
"5 6.180000e+18\n",
"6 0.000000e+00\n",
"7 0.000000e+00\n",
"8 3.000000e+16\n",
"9 0.000000e+00\n",
"10 0.000000e+00\n",
"11 0.000000e+00\n",
"12 0.000000e+00\n",
"13 0.000000e+00\n",
"14 0.000000e+00\n",
"Name: transaction_value, dtype: float64"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"transfers[\"transaction_value\"] = pd.to_numeric(transfers[\"transaction_value\"])\n",
"transfers[\"transaction_value\"] = transfers[\"transaction_value\"].fillna(0)\n",
"transfers[\"transaction_value\"].head(15)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"total_value_per_nft = transfers[\"nft_address\"].groupby(transfers[\"transaction_value\"]).sum()\n",
"total_value_per_nft.head(4)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"most_popular_nfts = transactions_per_nft.sort_values(ascending=False).head(8)\n",
"most_valuable_nfts = total_value_per_nft.sort_values(ascending=False).head(8)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#get frame with values over time\n",
"num_df = pd.DataFrame()\n",
"#cast to numeric\n",
"num_df = (transfers[[\"transaction_value\", \"timestamp\"]].apply(pd.to_numeric, errors='coerce'))\n",
"#add nft_address column to it\n",
"num_df[\"nft_address\"]=transfers[\"nft_address\"]\n",
"#filter out only ones that are in most_popular_nft variable\n",
"num_df = num_df[num_df.nft_address.isin(list(most_valuable_nfts.index))]\n",
"#convert timestamp in to date time\n",
"num_df[\"timestamp\"] = pd.to_datetime(num_df.timestamp, unit='s', errors='coerce')\n",
"#set index as timestamp\n",
"num_df = num_df.set_index(\"timestamp\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#group timestamps by day, create column per each nft_address, aggregate transaction value by count and sum\n",
"new_df = num_df.groupby([pd.Grouper(freq='d'), 'nft_address'])['transaction_value'].agg(transaction_value=\"sum\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# plt.figure(figsize=(24, 12))\n",
"# new_df.unstack()\n",
"# ax = sns.lineplot(data=new_df, x='timestamp', y='transaction_value', hue='nft_address',)"
]
},
{
"cell_type": "code",
"execution_count": null,