<jupyter_start><jupyter_text>Stablecoin Billionaires Descriptive Analysis of the Ethereum-based Stablecoin ecosystem   by <NAME>, 01.07.2020  Part II - USDC<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from datetime import datetime
from collections import Counter
from matplotlib import rc
import re
import random

rc('font', **{'family':'serif','serif': ['Computer Modern']})
rc('text', usetex=True)

#decimals
dec = 6
#plots
tx_over_date = '../plots/usdc/usdc_txs_over_date.csv'
unique_senders_over_date = '../plots/usdc/usdc_unique_senders_over_date.csv'
unique_recipients_over_date = '../plots/usdc/usdc_unique_recipients_over_date.csv'
tx_count_to = '../plots/usdc/usdc_tx_count_to.csv'
tx_count_from = '../plots/usdc/usdc_tx_count_from.csv'
tx_over_date = '../plots/usdc/usdc_txs_over_date.csv'
balances = '../plots/usdc/usdc_balances.csv'
avg_gas_over_date = '../plots/usdc/usdc_avg_gas_over_date.csv'
avg_value_over_date = '../plots/usdc/usdc_avg_value_over_date.csv'
positive_cumulated_balances = '../plots/usdc/usdc_positive_cumulated_balances.csv'
circulating_supply = '../plots/usdc/usdc_circulating_supply.csv'
unique_recipients_per_day_over_date = '../plots/usdc/usdc_unique_recipients_per_day_over_date.csv'
unique_senders_per_day_over_date = '../plots/usdc/usdc_unique_senders_per_day_over_date.csv'
exchanges = '../plots/exchanges.csv'

#data 
transfer = '../data/usdc/transfer/0_usdc_transfer_6082465-10370273.csv'
mint = '../data/usdc/mint/usdc_mint.csv'
burn = '../data/usdc/burn/usdc_burn.csv'<jupyter_output><empty_output><jupyter_text>Data<jupyter_code>df = pd.read_csv(transfer)
pd.set_option('display.float_format', lambda x: '%.3f' % x)<jupyter_output><empty_output><jupyter_text>Basics<jupyter_code>df['txvalue'] = df['txvalue'].astype(float)/10**dec
df.describe()
(df['txvalue']/10**6).describe()<jupyter_output><empty_output><jupyter_text>Dataset<jupyter_code>print('Start:')
print('Block: {:^30}\nTimestamp: {:^20}\nUTC Time: {:^25}\n'.format(df['blocknumber'].iloc[0],
                                                        df['timestamp'].iloc[0],
                                                        str(datetime.fromtimestamp(df['timestamp'].iloc[0]))
                                                       ))
print('End:')
print('Block: {:^30}\nTimestamp: {:^20}\nUTC Time: {:^25}\n'.format(df['blocknumber'].iloc[-1],
                                                        df['timestamp'].iloc[-1],
                                                        str(datetime.fromtimestamp(df['timestamp'].iloc[-1]))
                                                       ))<jupyter_output>Start:
Block:            6307510            
Timestamp:      1536604001     
UTC Time:    2018-09-10 20:26:41   

End:
Block:            10370273           
Timestamp:      1593561580     
UTC Time:    2020-07-01 01:59:40<jupyter_text>Total Nr. of Blocks<jupyter_code>print('Total Nr. of Blocks: {}'.format(df['blocknumber'].iloc[-1]-df['blocknumber'].iloc[0]))<jupyter_output>Total Nr. of Blocks: 4062763<jupyter_text>Total Nr. of Transfer Events<jupyter_code>print('Total Nr. of Events: {:,.0f}'.format(df.describe().loc['count','timestamp']))<jupyter_output>Total Nr. of Events: 2,991,712<jupyter_text>Total Nr. of Addresses<jupyter_code>print('Total Nr. of Addresses: {}'.format(len(df['txto'].unique())))<jupyter_output>Total Nr. of Addresses: 778227<jupyter_text>Addresses with funds<jupyter_code>bal = pd.read_csv(balances)
print('Total Nr. of Addresses with funds: {}'.format(len(bal[bal['txvalue']>0])))<jupyter_output>Total Nr. of Addresses with funds: 177495<jupyter_text>Avg. Transaction Value<jupyter_code>print('Avg. Transaction Value: {:,.0f} USDC'.format(np.mean(df['txvalue']/ 10**6)))<jupyter_output>Avg. Transaction Value: 19,655 USDC<jupyter_text>Total Gas Costs<jupyter_code>df['costs'] = (df['gas_price']/10**18) * df['gas_used']
print('Total Gas spent for Transfers: {:,.3f} ether'.format(sum(df['costs'])))<jupyter_output>Total Gas spent for Transfers: 19,143.105 ether<jupyter_text>Initial USDC Supply<jupyter_code>#first mint event
#0xdc6bb2a1aff2dbb2613113984b5fbd560e582c0a4369149402d7ea83b0f5983e<jupyter_output><empty_output><jupyter_text>Total USDC Supply<jupyter_code>sum(pd.read_csv(mint)['txvalue']/10**6)-sum(pd.read_csv(burn)['txvalue']/10**6)
df = pd.read_csv(transfer)
sum(df[df['txfrom'] == '0x0000000000000000000000000000000000000000']["txvalue"].astype(float))/(10**6)- sum(df[df['txto'] == '0x0000000000000000000000000000000000000000']["txvalue"].astype(float))/(10**6)<jupyter_output><empty_output><jupyter_text>I. Event analysis  I.I. Mint Event  Plot new issued tokens over date<jupyter_code>print('\n\n')
fig = plt.figure(figsize=(40,25), dpi=250)
ax = fig.subplots()
plt.grid()
plt.title(r'I s s u e d \ \ U S D C'+'\n', size= 120)
ax.yaxis.get_offset_text().set_fontsize(50)
plt.xlabel('\n'+r'D a t e ', size=120)
plt.ylabel(r'U S D C'+'\n', size=120)
plt.yticks(fontsize=60)
plt.xticks(labels=["Okt '18","\nJan '19",
                   "Apr '19","\nJul '19","Oct '19",
                   "\nJan '20","Apr '20","\nJul '20"], 
           ticks=[21,113,
                  203,294,386,
                  478,569,660], fontsize=60)

def plot_issue_over_date():
    _issue = pd.read_csv(mint)
    iss = _issue.loc[:, ['timestamp', 'txvalue']]
    iss['utc'] = iss['timestamp'].apply(lambda x: str(datetime.utcfromtimestamp(x))[0:10])
    iss = iss.groupby('utc', as_index = False)['txvalue'].sum()
    a = iss['utc'].iloc[0]
    b = iss['utc'].iloc[-1]
    idx = pd.date_range(a,b)
    iss = iss.set_index('utc')
    iss.index = pd.DatetimeIndex(iss.index)
    iss = iss.reindex(idx, fill_value=0)
    counter = 0
    for i in range(0, len(iss)):
        plt.plot([counter,counter], [0, iss['txvalue'].iloc[counter]/(10**6)], color= 'black', linewidth=3)
        counter += 1
    return 

plt.tight_layout(pad=5)
dfis = plot_issue_over_date()
plt.savefig('../pics/usdc/usdc_issued_usdc_over_date.pdf')<jupyter_output><empty_output><jupyter_text>Further info<jupyter_code>df = pd.read_csv(mint)
#df[df['txvalue'] == max(df['txvalue'])]
print('Issue Events: {}\nIssued USDC: {:,.0f}\n'.format(len(df), sum(df['txvalue'])/10**6, ':,0f'))
print('Largest issue: {:,.0f} USDC\n . . . to address: {}\n'.format(df.loc[3274, 'txvalue']//10**6,'0x55fe002aeff02f77364de339a1292923a15844b8'))<jupyter_output>Issue Events: 5358
Issued USDC: 2,645,276,543

Largest issue: 35,028,441 USDC
 . . . to address: 0x55fe002aeff02f77364de339a1292923a15844b8<jupyter_text>I.II. Burn Event  Plot burned tokens over date<jupyter_code>print('\n\n')
fig = plt.figure(figsize=(40,25))
ax = fig.subplots()
plt.grid()
plt.title(r'B u r n e d \ \ U S D C \ \ o v e r \ \ D a t e'+'\n', size= 120)
ax.yaxis.get_offset_text().set_fontsize(50)
plt.xlabel('\n'+r'D a t e', size=120)
plt.ylabel(r'U S D C'+'\n', size=120)
plt.yticks(fontsize=60)
plt.xticks(labels=["Okt '18","\nJan '19",
                   "Apr '19","\nJul '19","Oct '19",
                   "\nJan '20","Apr '20","\nJul '20"], 
           ticks=[6,98,
                  188,279,371,
                  463,554,645], fontsize=60)

def plot_burn_over_date():
    _dbf = pd.read_csv(burn)
    dbf = _dbf.loc[:, ['timestamp', 'txvalue']]
    dbf['utc'] = dbf['timestamp'].apply(lambda x: str(datetime.utcfromtimestamp(x))[0:10])
    dbf = dbf.groupby('utc', as_index = False)['txvalue'].sum()
    a = dbf['utc'].iloc[0]
    b = dbf['utc'].iloc[-1]
    idx = pd.date_range(a,b)
    dbf = dbf.set_index('utc')
    dbf.index = pd.DatetimeIndex(dbf.index)
    dbf = dbf.reindex(idx, fill_value=0)
    counter = 0
    for i in range(0, len(dbf)):
        plt.plot([counter,counter], [0, dbf['txvalue'].iloc[counter]/(10**6)], color= 'black', linewidth=3)
        counter += 1
    
    return

plt.tight_layout(pad=5)
plot_burn_over_date()
plt.savefig('../pics/usdc/usdc_burned_usdc_over_date.pdf')<jupyter_output><empty_output><jupyter_text>Further info<jupyter_code>df = pd.read_csv(burn)

print('Burn Events: {}\nBurned usdc: {:,.0f}'.format(len(df), sum(df['txvalue'])/10**6, ':,0f'))
print('. . . from {} addesses\n'.format(len(df['address'].unique())))
print('Largest burn: {:,.0f} usdc\n . . . from address: {}\n'.format(df.groupby('address')['txvalue'].sum()[0]/10**6,df.groupby("address")["txvalue"].sum().index[0]))<jupyter_output>Burn Events: 4659
Burned usdc: 1,659,736,363
. . . from 3 addesses

Largest burn: 200 usdc
 . . . from address: 0x24bdd8771b08c2ea6fe0e898126e65bd49021be3<jupyter_text>Plot circulating supply<jupyter_code>print('\n\n')
fig = plt.figure(figsize=(20,12), dpi=500)
ax = fig.subplots()
plt.grid(True)
plt.title(r'C i r c u l a t i n g \ \ U S D C \ \ S u p p l y'+'\n', size=60)
plt.xlabel('\n'+r'D a t e', size= 60)
plt.ylabel(r'U S D C'+'\n', size= 60)
ax.yaxis.get_offset_text().set_fontsize(25)

plt.yticks(fontsize=30)
plt.xticks(labels=["Okt '18","\nJan '19",
                   "Apr '19","\nJul '19","Oct '19",
                   "\nJan '20","Apr '20","\nJul '20"], 
           ticks=[21,113,
                  203,294,386,
                  478,569,660], fontsize=30)

circ = pd.read_csv(circulating_supply, index_col='Unnamed: 0')

plt.plot(range(0, 660), circ['txvalue'].cumsum()/10**6, color='black', linewidth = 4, label = 'USDC supply')
plt.fill_between(range(0, 660),0 , circ['txvalue'].cumsum()/10**6, alpha=0.2, facecolor='#2D728F')
lgnd = plt.legend(loc='upper left', fontsize=40)
plt.tight_layout(pad=5)
plt.savefig('../pics/usdc/usdc_cirulating_supply.pdf')<jupyter_output><empty_output><jupyter_text>I.III. Transfer Event  Plot transfers over date<jupyter_code>print('\n\n')
fig = plt.figure(figsize=(20,12), dpi=500)
ax = fig.subplots()
plt.grid(True)
plt.title(r'U S D C \ \ T r a n s f e r s'+'\n', size=60)
plt.xlabel('\n'+r'D a t e', size= 50)
plt.ylabel(r'U S D C'+'\n', size= 50)
plt.yticks(np.arange(0, 30001, 5000), 
           np.vectorize(lambda x: f'{x:,.0f}')(np.arange(0, 30001, 5000)), 
           fontsize=30)
plt.xticks(labels=["Okt '18","\nJan '19",
                   "Apr '19","\nJul '19","Oct '19",
                   "\nJan '20","Apr '20","\nJul '20"], 
           ticks=[21,113,
                  203,294,386,
                  478,569,660], fontsize=30)

def plot_txs_over_date(df, lwd, label, col = '#2D728F', plusbetween = False):
    plt.plot(np.arange(0 , len(df['txs'])), df['txs'], color = col, linewidth = lwd, label = label)
    if plusbetween:
        plt.fill_between(np.arange(0 , len(df['txs'])),0 , df['txs'], alpha=0.1, facecolor='#2D728F')
 
    
plot_txs_over_date(df = pd.read_csv(tx_over_date, index_col=0), 
                   col = 'black', lwd = 2, label = 'Transfers', plusbetween=True)

plot_txs_over_date(pd.read_csv(unique_senders_per_day_over_date, index_col='Unnamed: 0'), 
                   col='#9DB469', lwd = 2, label =  'Unique Senders per day')

plot_txs_over_date(pd.read_csv(unique_recipients_per_day_over_date, index_col='Unnamed: 0'), 
                   lwd = 2, label = 'Unique Recipients per day')




lgnd = ax.legend(loc='upper left', fontsize=35)
lgnd.legendHandles[0].set_linewidth(5.0)
lgnd.legendHandles[1].set_linewidth(5.0)
lgnd.legendHandles[2].set_linewidth(5.0)

plt.tight_layout(pad=5)
plt.savefig('../pics/usdc/usdc_tx_over_date.pdf')
plt.show()<jupyter_output><empty_output><jupyter_text>Most active addresses From:<jupyter_code>fr = pd.read_csv(tx_count_from, index_col='Unnamed: 0').sort_values('txs', ascending = False)
to = pd.read_csv(tx_count_to, index_col='Unnamed: 0').sort_values('txs', ascending = False)
fr = pd.DataFrame(fr.loc[:fr.index[10],'txs'])
fr['tag'] = ['Disperse.app', 'Uniswap: USDC', 'Binance', 'Kyber: Contract', 'Compound USD Coin', 'Binance 2', 'Binance 4', 'Binance 3', '1inch.exchange', 'Poloniex 4', '-']
fr<jupyter_output><empty_output><jupyter_text>To:<jupyter_code>to = pd.DataFrame(to.loc[:to.index[10],'txs'])
to['tag'] = ['Binance', 'Uniswap: USDC', 'Kyber: Contract', 'Compound USD Coin', '1inch.exchange', 'Kyber: Old Contract', 'BlockFi', 'Nexo: Wallet', 'Celsius Network: Contract ', '-', 'Nuo Network: Kernel Escrow']
to<jupyter_output><empty_output><jupyter_text>Activity distribution<jupyter_code>df_from = pd.read_csv(tx_count_from, index_col=0)
df_to = pd.read_csv(tx_count_to, index_col=0)
df_all = pd.concat([df_from, df_to])
df = df_all.groupby(df_all.index).sum()
print('{} addresses in total'.format(len(df)))
df = df.sort_values('txs')
gr0 = len(df.loc[df['txs'] >= 500000])
gra = len(df.loc[df['txs'] >= 100000]) - gr0 
grb = len(df.loc[df['txs'] >= 50000]) - gr0 - gra
grc = len(df.loc[df['txs'] >= 10000]) - gr0 - gra - grb
grd = len(df.loc[df['txs'] >= 1000]) - gr0 - gra - grb - grc
gre = len(df.loc[df['txs'] >= 100]) - gr0 - gra - grb - grc - grd
grf = len(df.loc[df['txs'] >= 10]) - gr0 - gra - grb - grc - grd - gre
grg = len(df.loc[df['txs'] <= 10])
grh = len(df.loc[df['txs'] == 1]) 
pd.DataFrame({'Transactions': ['> 500.000','100.000-500.000',
                               '50.000-100.000',
                               '10.000-50.000',
                               '1.000-10.000',
                               '100-1.000',
                               '10-100',
                               '< 10', 
                               '1'], 
              'Addresses':[gr0,gra,grb,grc,grd,gre,grf,grg,grh]
             })<jupyter_output>778574 addresses in total<jupyter_text>Plot average transfer amount  Jan '20 - Jul '20<jupyter_code>print('\n\n')
df = pd.read_csv(avg_value_over_date, index_col=0)
df = df.loc[df.index[478]:,:]
plt.figure(figsize=(12, 7), dpi=800)

plt.grid(True)
plt.plot(np.arange(0 , len(df.index.tolist())), df['txvalue'], color = 'black', label = 'Avg. Amount/Day', linewidth = 2)
plt.fill_between(np.arange(0 , len(df.index.tolist())),0 , df['txvalue'], alpha=0.2, facecolor='#2D728F')
plt.xlabel('\n'+'D a t e', fontsize=45)
plt.ylabel('U S D C'+'\n', fontsize=35)
plt.title("A v e r a g e \ \ T r a n s f e r \ \ A m o u n t"+"\n"+"J a n \ \ ' 2 0 \ \ - \ \ J u l \ \ ' 2 0\n", size = 30)
plt.legend(loc='upper right', fontsize=20, shadow= True)
plt.ticklabel_format(style = 'plain')
plt.xticks(labels=["\nJan '20","Feb '20","\nMar '20","Apr '20","\nMay '20","Jun '20","\nJul '20"], 
           ticks=[0,31,60,90,121,152,182], fontsize=23) 
plt.yticks(np.arange(0, 50001, 10000), 
           np.vectorize(lambda x: f'{x:,.0f}')(np.arange(0, 50001, 10000)), 
           fontsize=15)
plt.tight_layout(pad=1)
plt.savefig('../pics/usdc/usdc_avgtxvalue_jan20.pdf')<jupyter_output><empty_output><jupyter_text>Further Info<jupyter_code>df.describe()<jupyter_output><empty_output><jupyter_text>Plot average gas costs  Jan '20 - Jul '20<jupyter_code>print('\n\n')
df = pd.read_csv(avg_gas_over_date)
df = df.loc[df.index[478]:,:]
plt.figure(figsize=(12, 7), dpi=800)
plt.grid(True)
plt.plot(np.arange(0 , len(df.index.tolist())), df['gas'], color = 'black', label = 'Avg. Gas Costs/Day', linewidth = 2)
plt.fill_between(np.arange(0 , len(df.index.tolist())),0 , df['gas'], alpha=0.2, facecolor='#2D728F')
plt.xlabel('\n'+'D a t e', fontsize=35)
plt.ylabel('E t h e r'+'\n', fontsize=30)
plt.title("U S D C\nA v g. \ \ G a s \ \ C o s t s\n", size = 30)
lgnd = plt.legend(loc='upper left', fontsize=20, shadow= True)
plt.ticklabel_format(style = 'plain')
plt.xticks(labels=["\nJan '20","Feb '20","\nMar '20","Apr '20","\nMay '20","Jun '20","\nJul '20"], 
           ticks=[0,31,60,90,121,152,182], fontsize=20) 
plt.yticks(np.arange(0, 0.05, 0.01), 
           np.vectorize(lambda x: f'{x:,.3f}')(np.arange(0, 0.05, 0.01)), 
           fontsize=15)
plt.tight_layout(pad=1)
lgnd.legendHandles[0].set_linewidth(3.0)
plt.savefig('../pics/usdc/usdc_avggascosts_jan20.pdf') 
df.describe()<jupyter_output><empty_output><jupyter_text>II. Balances Analysis<jupyter_code>df = pd.read_csv(positive_cumulated_balances, index_col='Unnamed: 0')
df<jupyter_output><empty_output><jupyter_text>II.I. Quick Summary<jupyter_code>(df[df['balance']>0]['balance']).describe().apply(lambda x: format(x, 'f'))
print('{}/{} with less than 1 usdc' .format(len(df[df['balance']<1]['balance']), len(df['balance'])))<jupyter_output>92454/177495 with less than 1 usdc<jupyter_text>II.II. Balance Table<jupyter_code>df = pd.read_csv(positive_cumulated_balances, index_col=0)
def get_distribution(perc):
    per = round(df.index[-1]*perc)
    entities = df.index[-1]- per
    upper = df.loc[per:,:]
    lower = df.loc[:per,:]
    lower_ = lower['cum'].iloc[-1]
    upper_ = (upper['cum'].iloc[-1] - upper['cum'].iloc[0])
    return entities, lower_, upper_, lower_/ upper['cum'].iloc[-1], upper_/(upper['cum'].iloc[-1])

idx90, lower90, upper90, per10, per90 = get_distribution(0.90)
idx95, lower95, upper95, per05, per95 = get_distribution(0.95)
idx99, lower99, upper99, per01, per99 = get_distribution(0.99)
idx999, lower999, upper999, per001, per999 = get_distribution(0.999)

df = pd.DataFrame([[f'{idx999:,.0f}', round(per999*100,2), f'{upper999:,.0f}'],
             [f'{idx99:,.0f}', round(per99*100,2),f'{upper99:,.0f}'],
             [f'{idx95:,.0f}', round(per95*100,2),f'{upper95:,.0f}'],
             [f'{idx90:,.0f}', round(per90*100,2),f'{upper90:,.0f}']],
                  index=['0.1% of the richest accounts', '1% of the richest accounts','5% of the richest accounts','10% of the richest accounts'],
                   columns=['Accounts in total', '% of total supply', 'usdc amount'])
df<jupyter_output><empty_output><jupyter_text>II.III. Rich list<jupyter_code>pd.options.mode.chained_assignment = None
df = pd.read_csv(positive_cumulated_balances)
balance = df
rich = df.loc[df.index[-10]:,:]
ex = pd.read_csv(exchanges, header=None)
loop = rich.iterrows()
for i, j in loop:
    if j['address'] in ex[0].tolist():
        rich.loc[i,'nametag'] = ex[ex[0] == j['address']][1].values[0]

rich.loc[177493,'nametag'] = 'Binance/FTX'
rich.loc[177492,'nametag'] = 'Binance?'
rich<jupyter_output><empty_output><jupyter_text>Huobi<jupyter_code>ex = pd.read_csv(exchanges, header=None)
df = ex.loc[0:73,:]
bal = 0 
for i in df[0]:
    val = balance['balance'][balance['address'] == i]
    if not val.empty:
        bal += balance['balance'][balance['address'] == i].values[0]
    else:
        pass
print('Huobi Total Balance: {:.0f}\n{:.2f}% of Total'.format(bal, bal/balance.loc[balance.index[-1], 'cum']*100))<jupyter_output>Huobi Total Balance: 14687912
1.49% of Total<jupyter_text>Binance<jupyter_code>df = ex.loc[74:88,:]
bal = 0 
for i in df[0]:
    val = balance['balance'][balance['address'] == i]
    if not val.empty:
        bal += balance['balance'][balance['address'] == i].values[0]
    else:
        pass
print('Binance Total Balance: {:.0f}\n{:.2f}% of Total'.format(bal, bal/balance.loc[balance.index[-1], 'cum']*100))<jupyter_output>Binance Total Balance: 69599342
7.06% of Total<jupyter_text>Bitfinex<jupyter_code>df = ex.loc[89:110,:]
bal = 0 
for i in df[0]:
    val = balance['balance'][balance['address'] == i]
    if not val.empty:
        bal += balance['balance'][balance['address'] == i].values[0]
    else:
        pass
print('Bitfinex Total Balance: {:.0f}\n{:.2f}% of Total'.format(bal, bal/balance.loc[balance.index[-1], 'cum']*100))<jupyter_output>Bitfinex Total Balance: 1535922
0.16% of Total<jupyter_text>OKEx<jupyter_code>df = ex.loc[111:115,:]
bal = 0 
for i in df[0]:
    val = balance['balance'][balance['address'] == i]
    if not val.empty:
        bal += balance['balance'][balance['address'] == i].values[0]
    else:
        pass
print('OKEx Total Balance: {:.0f}\n{:.2f}% of Total'.format(bal, bal/balance.loc[balance.index[-1], 'cum']*100))<jupyter_output>OKEx Total Balance: 1100618
0.11% of Total<jupyter_text>Bittrex<jupyter_code>df = ex.loc[116:119,:]
bal = 0 
for i in df[0]:
    val = balance['balance'][balance['address'] == i]
    if not val.empty:
        bal += balance['balance'][balance['address'] == i].values[0]
    else:
        pass
print('Bittrex Total Balance: {:.0f}\n{:.2f}% of Total'.format(bal, bal/balance.loc[balance.index[-1], 'cum']*100))<jupyter_output>Bittrex Total Balance: 591189
0.06% of Total<jupyter_text>Compound<jupyter_code>df = ex.loc[151:179,:]
bal = 0 
for i in df[0]:
    val = balance['balance'][balance['address'] == i]
    if not val.empty:
        bal += balance['balance'][balance['address'] == i].values[0]
    else:
        pass
print('Compound Total Balance: {:.0f}\n{:.2f}% of Total'.format(bal, bal/balance.loc[balance.index[-1], 'cum']*100))<jupyter_output>Compound Total Balance: 204069453
20.71% of Total<jupyter_text>Poloniex<jupyter_code>df = ex.loc[247:266,:]
bal = 0 
for i in df[0]:
    val = balance['balance'][balance['address'] == i]
    if not val.empty:
        bal += balance['balance'][balance['address'] == i].values[0]
    else:
        pass
print('Poloniex Total Balance: {:.0f}\n{:.2f}% of Total'.format(bal, bal/balance.loc[balance.index[-1], 'cum']*100))<jupyter_output>Poloniex Total Balance: 7417559
0.75% of Total<jupyter_text>II. IV. Pie Chart<jupyter_code>df = pd.read_csv(positive_cumulated_balances, index_col='Unnamed: 0')
aa = df.iloc[df.index[-1]-80:]
bb = df['balance'].iloc[:df.index[-1]-80]
df = aa.append(pd.DataFrame({'address': 'others', 'balance': sum(bb)}, index=[0]))
label = []
counter = 0
def getlabel(i):
    global counter
    if i:
        if not i == 'others':
            label.append(i + '...')
        else:
            label.append(i)
    else:
        label.append('')
    counter += 1
    
[getlabel(i[:6]) if counter >= len(df)-12 else getlabel('') for i in df['address']  ]
print()
print('\n\n')
# Colorspace colors by: https://colorspace.r-forge.r-project.org/index.html

colorspace_set3 = ['#EEBD92','#FFB3B5','#85D0F2','#BCC3FE','#E7B5F5', 
                 '#FEAFDA', '#61D8D6','#76D9B1','#A4D390','#CFC982']
colorsp_dynamic =['#DB9D85', '#87AEDF', '#9DB469', '#6DBC86', '#3DBEAB', 
                  '#4CB9CC', '#C2A968', '#BB9FE0', '#DA95CC', '#E494AB']
colorspa_dark_3 = ['#B675E0','#5991E4','#00AA5A','#6F9F00','#CE7D3B']
colorspa_dyna_5 = ['#9DB469','#87AEDF','#DA95CC', '#DB9D85','#3DBEAB']

fig = plt.figure(figsize=(25,15), dpi=400)
ax = fig.add_subplot()
aa = plt.pie(df['balance'],colors=colorsp_dynamic, 
             labels=label,
             autopct=lambda x: r'{:.1f}\%'.format(x) if x > 1.5 else r'{:.0f}\%'.format(x) if x > 5  else '', 
             pctdistance= 0.8, 
             labeldistance= 1.05, 
             radius=1, 
             explode=[0.05 for i in range(0, len(df['balance']))],
             wedgeprops = {'linewidth': 0.8, 'edgecolor':'k'}, 
             startangle=220) 

# Custom Modifications
aa[-1][-1].set_x(-0.7268917458682129)
aa[-1][-1].set_fontsize(35)
aa[-1][-2].set_fontsize(30)
aa[-1][-2].set_x(0.19977073082370535)
aa[-1][-2].set_y(0.8000006952023211)
aa[-1][-3].set_fontsize(27)
aa[-1][-4].set_fontsize(23)
aa[-1][-5].set_fontsize(20)
aa[-1][-6].set_fontsize(16)
aa[-1][-7].set_fontsize(13)
aa[-1][-8].set_fontsize(9)
aa[-1][-9].set_fontsize(9)
aa[-1][-10].set_fontsize(9)
aa[-1][-11].set_fontsize(8)

fontsize = -43
for i in aa[1]:
    i.set_fontsize(fontsize)
    fontsize += 1
aa[1][-1].set_fontsize(55)
plt.tight_layout(pad=5)
plt.title('U S D C \ \ D i s t r i b u t i o n', fontsize = 50)
circ = plt.Circle((0,0),0.5,color='black', fc='white',linewidth=1.25)
ax.add_artist(circ)
plt.savefig('../pics/usdc/usdc_distribution_pie.pdf')<jupyter_output><empty_output><jupyter_text>II.V. Lorenz curve<jupyter_code>df = pd.read_csv(positive_cumulated_balances, index_col = 'Unnamed: 0')
df
y_all = df['cum']/df['cum'].iloc[-1]
x_all = (np.arange(start = 0 , stop = len(df['cum']), step = 1)/(len(df['cum'])))

y_25_75 = df['cum'].iloc[int(df.index[-1]*0.25):int(df.index[-1]*0.75)]
y_25_75 = y_25_75/max(y_25_75)
x_25_75 = np.arange(start = 0 , stop = len(y_25_75), step = 1)/(len(y_25_75))
print('Q3-Q1 (in usdc):')
df['balance'].iloc[int(df.index[-1]*0.25):int(df.index[-1]*0.75)].describe().apply(lambda x: format(x/(10**0), 'f'))
print('\n\n')
fig = plt.figure(figsize=(15,15))
ax = fig.add_subplot()
plt.grid()
plt.title(r'L o r e n z \ \ C u r v e'+'\n', fontsize=50)
plt.xlabel('\n'+r'\% \ \ of \ \ A d d r e s s e s', fontsize=30)
plt.ylabel(r'\% \ o f \ \ t o t a l \ \ U S D C \ \ s u p p l y'+'\n',  fontsize=30)
plt.xticks(fontsize=20)
plt.yticks(fontsize=20)
ax.plot(x_all,y_all, linewidth = 5, color = '#2D728F', label = r'$\ All$')
ax.plot(x_25_75,y_25_75, linewidth = 5, color = '#87AEDF', label = r'$\ Q_3 - Q_1$')
plt.legend(fontsize= 35)
plt.plot([0, 1], [0, 1], transform=ax.transAxes, linewidth = 4, ls = (0, (5, 10)), color = 'black')
ax.set_xlim([0,1.05])
plt.savefig('../pics/usdc/uscd_lorenzcurve.pdf')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19956264679679275, 'fraction_numerical': 0.07179881752652466, 'mean_word_length': 4.02441505595117, 'pattern_counts': {'":': 0, '<': 135, '<?xml version=': 0, '>': 145, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 35, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '37', 'dir': 'jupyter-structured-clean-dedup', 'id': '28240', 'license': 'Apache-2.0', 'n_tokens_mistral': 11154, 'n_tokens_neox': 9902, 'n_words': 1685, 'path': 'individual_token_analysis/.ipynb_checkpoints/usdc_descriptive_analysis-checkpoint.ipynb', 'repo_name': 'Nerolation/Stablecoin-Billionaires', 'size': '24705'}