犯罪タイプが多いから、SQLで縦横変換はちょっと煩雑。データラングリングに長けたExploratryで時短します。常に進化し続けるBIツール、正しく使えれば強力すぎる武器。
- 使用データ:[ Google Cloud Public Datasets] chicago_crime_data (Chicago Police Department crime data from 2001 to present)
- 期間:2010-01-01 ~ 2020-12-31(10年間)
経過
ひとつのデータソースを①「Tableau」②「Exploratry」③「Flourish」それぞれで可視化しています。比較のために見た目、色、できるだけ揃えます。
①②は同じデータで良かったけど、③はそのまま使えないことに気付く(過去記事「ロング型からワイド型へのデータ変換①」)。データソースをテンプレの配列に合うよう変えることにしました。
データ変換作業で「SQL」を使うと、コードが長くなることが判明。時短とミス防止のため、データクリーニングにも長けたBIツール「Exploratry」でデータ変換を行います。
推せるUI
(作業ではないので読み飛ばし可:これからもちょいちょい出るであろう推しコメ)Exploratryの素敵なところ。作業過程が見える。過去と現在を自在に移動できる。Ctrl+Zじゃなくて、時系列と結果が並列で画面に表示されます。
過去に戻れるうえに、ブランチで並行世界に行くこともできます(表現がヲタ)。妄想をプロダクトに落とし込むUIたまらん。
作業経過
- 年でグループ化
- ロング型からワイド型へ
1.年でグループ化
では。現状のデータを年でグループ化します。ぱっと見変わらないですけど、動いてます。背景のパステルカラーも好き。(一度惚れると他が勝たん)
2.ロング型からワイド型へ
この機能がすでに入ってます。神か。設定画面でキー列と対象にする列を決めます。
さらにNULL処理もできる!デフォルトは「N/A」です。今回はNULL=入力する事件がない=0なので、「0」を入れます。
プレビューもできるんですよ~。このBIツールに出会えてほんとよかった。
実行して、グループ解除して、列を並び替えて(この理由はFlourish編で)、CSVでエクスポートします。うむ。早かった。
********
There are many types of crime, so vertical and horizontal conversion in SQL is a bit complicated. Shorten the time with Exploratry, which is good at data wrangling. A constantly evolving BI tool, too powerful a weapon if used correctly.
- Data used: [ Google Cloud Public Datasets] chicago_crime_data (Chicago Police Department crime data from 2001 to present)
- Period: 2010-01-01 - 2020-12-31 (10 years)
Progress
Visualise one data source each in (1) 'Tableau', (2) 'Exploratry' and (3) 'Flourish'. I try to match the look, colours and as much as possible for comparison.
Notice that (1) and (2) worked well with the same data, but (3) cannot be used as is (previous article "Data conversion from long type to wide type (1)"). I decided to change the data source to match the template array.
Using 'SQL' in the data conversion process turned out to make the code longer. To save time and avoid errors, the data conversion is done using the BI tool 'Exploratry', which is also adept at data cleansing.
UI that can be recommendation.
(You can skip this because it is not work) Exploratry's UI is nice. I can see the workflow. You can move freely between past and present, not Ctrl+Z, and the timeline and results are on the screen in parallel.
You can go back in time and branch out to parallel worlds. The UI is a nice way to put my fantasies into a product.
Work progress
- Grouping by year
- Change from long type to wide type
1.Grouping by year
Now let's. Group the current data by year. It doesn't look the same at a glance, but it is working. The pastel colours of the background are cute.
2. Change from long type to wide type
This feature is already included. God. You decide which key columns and which columns to target in the settings screen.
You can also handle NULLs! The default is 'N/A'. This time, NULL = no criminal case = 0, so enter '0'
I can even preview it. I'm really glad I found this BI tool.
Run it, ungroup, reorder the columns (for this reason in the Flourish ver. article), and export as CSV. Hmmm. That was quick.
0コメント