This time, I will change my mind a little and introduce an example of simple data analysis (visualization) using Python. CoinMetrics provides data of each cryptocurrency (including stable coins) in csv format, so I used that to visualize the transaction volume and price (USD) of Bitcoin.
Since Python has abundant libraries for data analysis, it is nice to have only a few lines to dozens of lines for simple visualization. (In this case, it is possible to visualize somehow with a very simple code just by using pandas and matplotlib. When trying to realize the same thing with MS-Excel ...)
**
getCoinMetrics
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
data = pd.read_csv('xxx\\btc.csv')
data['date'] = pd.to_datetime(data['date'])
data.set_index('date', inplace=True)
**
plt.plot(data.TxCnt)
** <Visualize price (USD) transitions by year> **
plt.plot(data.PriceUSD)
** <Representing the annual transition status of transaction volume and price (USD) in a composite graph> **
fig, ax1 = plt.subplots()
plt.plot(data.TxCnt, color='darkblue', label='TxCnt')
ax2 = ax1.twinx()
plt.plot(data.PriceUSD, color='darkorange', label='PriceUSD')
h1, l1 = ax1.get_legend_handles_labels()
h2, l2 = ax2.get_legend_handles_labels()
ax1.legend(h1+h2, l1+l2, loc='upper left')
ax1.set_xlabel('date')
ax1.set_ylabel('TxCnt')
ax2.set_ylabel('PriceUSD')
** <By the way, it is possible to narrow down to a specific year (example: 2014)> **
Excerpt only for changes
~
plt.plot(df_data['2014'].TxCnt, color='darkblue', label='TxCnt')
~
plt.plot(df_data['2014'].PriceUSD, color='darkorange', label='PriceUSD')
~
**
plt.scatter(data.TxCnt,data.PriceUSD)
that's all
Recommended Posts