[PYTHON] Basics of Tableau Basics (Visualization Using Geographic Information)

Recently, I summarized the basic usage of BI tool "Tableau" introduced as a set with AWS. Tableau is a very simple tool, so anyone who can use Excel can easily visualize the data.

August 3, 2019 Added Some information has been updated and re-edited and posted on my blog. Have a look at this. https://tadaken3.hatenablog.jp/entry/tableau-map

See also the following sites for "Tableau".

-[Tableau Official Website](http://get.tableau.com/ja-jp/trial/tableau-software.html?cid=70160000000YmmJ&ls=Paid%20Search&lsd=Google%20AdWords%20-%20Tableau%20-%20APAC % 20-% 20JP% 20-% 20Free% 20Trial & adgroup = Tableau% 20-% 20Brand% 20-% 20All & kw = tableau & adused = 54853941890 & distribution = search & gclid = Cj0KEQiA-NqyBRC905irsrLr-LUBEiQAWJFYTuwQDatz8JFYTuwQDatz -Summary of what you can do with Tableau Desktop -Introduction of Tableau Public ~ BI tool with excellent visualization that can be used on the Web ~ | Thinking about analysis environment

This time I'm using tableau Public, which can be used for free. It's almost the same functionality as the retail version of tableau Desktop. Click here for DL site ↓ https://public.tableau.com/s/

Data preparation

Using Python's Pandas module, Data is obtained from the "Population List by Prefecture" page of Wikipedia. ~~ (tableau public can only handle text files, so it outputs CSV files. With the product version, you can get the data directly from the DB) ~~

Starting with tableau 10.0, tableau public now supports Google Sheets and Web Data Connector. What's more, when Google Sheets is updated, it will be automatically updated by date and time processing. tableau public Too much beginning. (Addition: 2016-10-05)

import pandas as pd

url = 'https://ja.wikipedia.org/wiki/%E9%83%BD%E9%81%93%E5%BA%9C%E7%9C%8C%E3%81%AE%E4%BA%BA%E5%8F%A3%E4%B8%80%E8%A6%A7'
fetched_dataframes = pd.read_html(url, header = 0)
df = fetched_dataframes[0]
df.to_csv("population.csv", index = False,encoding='utf-8')	 

Data reading

Launch tableau public and load the CSV file. No special settings are required. (It is a file called population.csv)

スクリーンショット 2015-11-26 22.49.48.png

Data visualization

This time, I would like to calculate the population increase / decrease rate for each prefecture and visualize it on a map. First, we will calculate the population increase / decrease rate. I will enter the calculation formula like Excel. I haven't used it this time, but there are functions available, and it's really easy to calculate like Excel.

スクリーンショット 2015-11-26 22.22.45.png

Since we want to use a map this time, specify "Geographical role" for the dimension "Prefecture". Since it is a tool in the United States, it is a "state", but if you specify this, it will recognize the prefectures of Japan properly. スクリーンショット 2015-11-26 22.21.35.png

If you double-click on a prefecture, "Tableau" will automatically recognize it and select the most suitable visual expression. In this case, the map is displayed because the geographical information is set. (Of course, you can also set it yourself.) This time, I want to express it in color by the population increase / decrease rate, so I will put the measure of the "population increase / decrease rate" created earlier in the mark part. スクリーンショット 2015-11-26 22.23.42.png

Select "Population Increase / Decrease Rate" and specify "Color". スクリーンショット 2015-11-26 22.23.51.png Then, each prefecture will be color-coded according to the population increase / decrease rate. Except for Kanto, it's almost bright red. スクリーンショット 2015-11-26 23.09.00.png

The rest is completed by supplementing with formats and comments. The completed file can be uploaded and published on the official tableau publlic website. It is like this.

都道府県別の人口増減率.png

Recommended Posts

Basics of Tableau Basics (Visualization Using Geographic Information)
python: Basics of using scikit-learn ①
Visualization of mixed matrices using sklearn.metrics.ConfusionMatrixDisplay
Basics of Quantum Information Theory: Entropy (2)
Python: Basics of image recognition using CNN
Basics of Quantum Information Theory: Data Compression (1)
Basics of Quantum Information Theory: Trace Distance
Basics of Quantum Information Theory: Quantum State Tomography
Basics of Quantum Information Theory: Data Compression (2)
How to use folium (visualization of location information)
[Pandas] Basics of processing date data using dt
Basics of Python ①
Basics of Quantum Information Theory: Topological Toric Code
Basics of Quantum Information Theory: Fault Tolerant Quantum Computation
Geographic information visualization of R and Python that can be expressed in Power BI
Basics of I / O screen using tkinter in python3
Basics of Quantum Information Theory: Quantum Error Correction (Shor's Code)
Two-dimensional visualization of document vectors using Word2Vec trained model
Basics of Quantum Information Theory: Quantum Error Correction (Stabilizer Code: 4)
Basics of Python scraping basics
# 4 [python] Basics of functions
Basics of network programs?
Basics of Perceptron Foundation
Basics of regression analysis
Example of using lambda
Basics of python: Output
Basics of Quantum Information Theory: Quantum Error Correction (Classical Linear Code)
Basics of Quantum Information Theory: Universal Quantum Calculation by Toric Code (1)
Using MLflow with Databricks ② --Visualization of experimental parameters and metrics -