A simple data analysis of Bitcoin provided by CoinMetrics in Python

【Text】

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 ...)

** ** The data provided by CoinMetrics can be downloaded from the following (Data from major cryptocurrencies can be used) https://coinmetrics.io/community-network-data/

[Python code]

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)

TxCnt.png

** <Visualize price (USD) transitions by year> **

plt.plot(data.PriceUSD)

PriceUSD_btc.png

** <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')

TxCnt_PriceUSD_btc.png

** <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')
~

TxCnt_PriceUSD_btc_2014.png

** **

plt.scatter(data.TxCnt,data.PriceUSD)

scatter_btc.png

that's all

Recommended Posts

A simple data analysis of Bitcoin provided by CoinMetrics in Python
A well-prepared record of data analysis in Python
Data analysis in Python: A note about line_profiler
[Python] [Word] [python-docx] Simple analysis of diff data using python
List of Python code used in big data analysis
Simple regression analysis in Python
Basic data frame operations written by beginners in a week of learning Python
Group by consecutive elements of a list in Python
Implementing a simple algorithm in Python 2
Run a simple algorithm in Python
[Python] A memo of frequently used phrases (by myself) in Python scripts
Read the standard output of a subprocess line by line in Python
Practice of data analysis by Python and pandas (Tokyo COVID-19 data edition)
The first time a programming beginner tried simple data analysis by programming
Impressions of touching Dash, a data visualization tool made by python
A simple HTTP client implemented in Python
Display a list of alphabets in Python 3
Try drawing a simple animation in Python
Create a simple GUI app in Python
Example of 3D skeleton analysis by Python
Write a simple greedy algorithm in Python
Write a simple Vim Plugin in Python 3
Analysis of X-ray microtomography image by Python
How to send a visualization image of data created in Python to Typetalk
A summary of Python e-books that are useful for free-to-read data analysis
Code reading of faker, a library that generates test data in Python
Data analysis python
Set up a simple HTTPS server in Python 3
Get the caller of a function in Python
Make a copy of the list in Python
Real-time visualization of thermography AMG8833 data in Python
A memorandum of extraction by python bs4 request
Rewriting elements in a loop of lists (Python)
A simple Pub / Sub program note in Python
Create a simple momentum investment model in Python
The story of reading HSPICE data in Python
Make a joyplot-like plot of R in python
Output in the form of a python array
Set up a simple SMTP server in Python
Sentiment analysis of large-scale tweet data by NLTK
Get a glimpse of machine learning in Python
A story about data analysis by machine learning
Data analysis in Python Summary of sources to look at first for beginners
[Python] Plot data by prefecture on a map (number of cars owned nationwide)
Data analysis with python 2
Create a data collection bot in Python using Selenium
2. Multivariate analysis spelled out in Python 1-1. Simple regression analysis (scikit-learn)
Analysis of financial data by pandas and its visualization (2)
Summary of tools needed to analyze data in Python
Simple gRPC in Python
Summary of statistical data analysis methods using Python that can be used in business
Get a large amount of Starbucks Twitter data with python and try data analysis Part 1
Power BI visualization of Salesforce data entirely in Python
Analysis of financial data by pandas and its visualization (1)
Data analysis using Python 0
Receive dictionary data from a Python program in AppleScript
Data analysis overview python
A collection of code often used in personal Python
Make a simple Slackbot with interactive button in python
Consolidate a large number of CSV files in folders with python (data without header)
Calculate the regression coefficient of simple regression analysis with python