<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kris Chavez on Medium]]></title>
        <description><![CDATA[Stories by Kris Chavez on Medium]]></description>
        <link>https://medium.com/@chavez.kris3?source=rss-123c42e7f641------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*TjWOtKaQSmCS1MXs</url>
            <title>Stories by Kris Chavez on Medium</title>
            <link>https://medium.com/@chavez.kris3?source=rss-123c42e7f641------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:48:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chavez.kris3/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Pixar Film Data Warehouse Project]]></title>
            <link>https://medium.com/@chavez.kris3/pixar-film-data-warehouse-project-d5f8699ef9df?source=rss-123c42e7f641------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5f8699ef9df</guid>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[data-warehouse]]></category>
            <category><![CDATA[pixar]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Kris Chavez]]></dc:creator>
            <pubDate>Wed, 02 Jul 2025 00:45:52 GMT</pubDate>
            <atom:updated>2025-07-09T23:38:21.343Z</atom:updated>
            <content:encoded><![CDATA[<h4>Exploring Pixar films from 1995 to 2024</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/0*DDSLEFDDIA5gprzv.gif" /></figure><h4>🔔Acknowledgment: 🔔</h4><p>I would like to thank <strong>Data with Baraa </strong>on YouTube, for the help on this project.</p><p>This project was created from my attempt to follow, understand and apply the free content provided from the following video:</p><p><a href="https://www.youtube.com/watch?v=9GVqKuTVANE&amp;list=PLHpdSsDL8VgsFgK1foT_H0ryuP99Mot1d&amp;index=22"><strong><em>SQL Data Warehouse from Scratch | Full Hands-On Data Engineering Project</em></strong></a></p><p>For anyone reading this blog, please like, comment and subscribe to Baraa’s YouTube as this project wouldn’t be done without his help.</p><h4><strong>Objective: 🎯</strong></h4><p>Build a Data Warehouse to organize, structure, prepare and explore the Pixar Film dataset.</p><h4>Pre-requisite: ⚠️</h4><ul><li>Have a copy of the <a href="https://www.kaggle.com/datasets/willianoliveiragibin/pixar-films">Pixar Films Dataset</a></li><li>SQL Server must be installed</li></ul><h4>Data Architecture: 🏦</h4><p>The main approach that was utilized within this project is the <a href="https://www.databricks.com/glossary/medallion-architecture"><strong>Medallion Architecure</strong>.</a></p><p>In essence, this architecture is split into 3 sections.</p><ol><li><strong>Bronze</strong>: Raw data</li><li><strong>Silver</strong>: Filtered and Cleaned data</li><li><strong>Gold</strong>: Business-Ready data</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DuKX5SF5_C0euvnb3C38vQ.png" /><figcaption>High Level Architecture: Data Warehouse (image by author)</figcaption></figure><h4>Overview: 📝</h4><p>For each layer, this project will go through the following:</p><ol><li><strong>Bronze</strong>: <br>- Create DDL for tables<br>- Develop SQL Load Scripts<br>- Create a Stored Procedure</li><li><strong>Silver</strong>: <br>- Create DDL for tables<br>- Develop SQL Load script from <em>Bronze to Silver </em>table<br>- Create a Stored Prodecure</li><li><strong>Gold</strong>:<br>- Create DDL for tables<br>- Business-Ready Data</li></ol><h4>Data Flow: 📅</h4><p>Once the data has been imported (Bronze) the next step is to Transform the data (Silver) so that other teams/analysts can use it (Gold).</p><p>As such, for every new changes made to the dataset; it is imperative we have a solid architecture to manage these changes — this way we will have a robust and scalable model that can easily be adjusted for future use.</p><p>In cases where a new change is required ie. adding new table or updating the current dataset, the process follows:</p><ol><li><strong>Bronze</strong>: Edit the DDL &amp; Load Script</li><li><strong>Silver</strong>: Edit the DDL &amp; Load Script + Run the stored procedure (only run this if there are no new tables to add)</li><li><strong>Gold</strong>: Edit the DDL</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*UHyQw0OhnHydr3jOiThsOQ.png" /><figcaption>Data Flow diagram (image by author)</figcaption></figure><h4>Data Integration: 📥</h4><p>Below is a diagram depicting how the files are related. I’ve split all 6 files into 2 sections.</p><ol><li>Film Description</li><li>Aggregate Metrics: Everything relating/having numbers.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*ByoAL2CA2U5KKeJyneYAcg.png" /><figcaption>Data Integration (image by author)</figcaption></figure><h3>1.0 Create Database and Schema 📅</h3><pre>/*<br>=============================================================<br>Create Database and Schemas<br>=============================================================<br>Script Purpose:<br>    This script creates a new database named &#39;films&#39; after checking if it already exists. <br>    If the database exists, it is dropped and recreated. Additionally, the script sets up three schemas <br>    within the database: &#39;bronze&#39;, &#39;silver&#39;, and &#39;gold&#39;.<br> <br>WARNING:<br>    Running this script will drop the entire &#39;DataWarehouse&#39; database if it exists. <br>    All data in the database will be permanently deleted. Proceed with caution <br>    and ensure you have proper backups before running this script.<br>*/<br><br>USE master;<br>GO<br><br>-- Drop and recreate the &#39;DataWarehouse&#39; database<br>IF EXISTS (SELECT 1 FROM sys.databases WHERE name = &#39;films&#39;)<br>BEGIN<br>    ALTER DATABASE films SET SINGLE_USER WITH ROLLBACK IMMEDIATE;<br>    DROP DATABASE films;<br>END;<br>GO<br><br>-- Create the &#39;films&#39; database<br>CREATE DATABASE films;<br>GO<br><br>USE films;<br>GO<br><br>-- Create Schemas<br>CREATE SCHEMA bronze;<br>GO<br><br>CREATE SCHEMA silver;<br>GO<br><br>CREATE SCHEMA gold;<br>GO</pre><h3>2.0 Create Bronze Layer 🟫</h3><p>In this layer, the goal is to normalize, import and load the dataset into SQL.</p><p>This is where we also define the naming conventions that will be implemented to the entire project.</p><h4>2.1 Create DDL for tables</h4><pre>/*<br>===============================================================================<br>DDL Script: Create Bronze Tables<br>===============================================================================<br>Script Purpose:<br>    This script creates tables in the &#39;bronze&#39; schema, dropping existing tables <br>    if they already exist.<br>   Run this script to re-define the DDL structure of &#39;bronze&#39; Tables<br>===============================================================================<br>*/<br><br>IF OBJECT_ID(&#39;bronze.academy&#39;, &#39;U&#39;) IS NOT NULL<br>    DROP TABLE bronze.academy;<br>GO<br><br>CREATE TABLE bronze.academy (<br>    film             NVARCHAR(50),<br>    award_type   NVARCHAR(50),<br>    status    NVARCHAR(50)<br>);<br>GO<br><br><br>IF OBJECT_ID(&#39;bronze.box_office&#39;, &#39;U&#39;) IS NOT NULL<br>    DROP TABLE bronze.box_office;<br>GO<br><br>CREATE TABLE bronze.box_office (<br>    film     NVARCHAR(50),<br>    budget     INT,<br>    box_office_us_canada INT,<br>    box_office_other  INT,<br>    box_office_worldwide INT<br>);<br>GO<br><br><br>IF OBJECT_ID(&#39;bronze.genres&#39;, &#39;U&#39;) IS NOT NULL<br>    DROP TABLE bronze.genres;<br>GO<br><br>CREATE TABLE bronze.genres (<br>    film     NVARCHAR(50),<br>    category    NVARCHAR(50),<br>    genre_value    NVARCHAR(50)<br>);<br>GO<br><br><br>IF OBJECT_ID(&#39;bronze.pixar_films&#39;, &#39;U&#39;) IS NOT NULL<br>    DROP TABLE bronze.pixar_films;<br>GO<br><br>CREATE TABLE bronze.pixar_films (<br>    number    INT,<br>    film    NVARCHAR(50),<br>    release_date  DATE,<br>    run_time   INT,<br>    film_rating   NVARCHAR(50),<br>    plot    NVARCHAR(255)<br>);<br>GO<br><br><br>IF OBJECT_ID(&#39;bronze.pixar_people&#39;, &#39;U&#39;) IS NOT NULL<br>    DROP TABLE bronze.pixar_people;<br>GO<br><br>CREATE TABLE bronze.pixar_people (<br>    film    NVARCHAR(50),<br>    role_type   NVARCHAR(50),<br>    person_name   NVARCHAR(50)<br>);<br>GO<br><br><br>IF OBJECT_ID(&#39;bronze.public_response&#39;, &#39;U&#39;) IS NOT NULL<br>    DROP TABLE bronze.public_response;<br>GO<br><br>CREATE TABLE bronze.public_response (<br>    film     NVARCHAR(50),<br>    rotten_tomatoes_score INT,<br>    rotten_tomatoes_counts INT,<br>    metacritic_score  INT,<br>    metacritic_counts  INT,<br>    cinema_score   NVARCHAR(50),<br>    imdb_score    FLOAT,<br>    imdb_counts    INT<br>);<br>GO</pre><h4>2.2 Bulk loading the dataset + Create Stored Procedure</h4><pre>/*<br>===============================================================================<br>Stored Procedure: Load Bronze Layer (Source -&gt; Bronze)<br>===============================================================================<br>Script Purpose:<br>    This stored procedure loads data into the &#39;bronze&#39; schema from external CSV files. <br>    It performs the following actions:<br>    - Truncates the bronze tables before loading data.<br>    - Uses the `BULK INSERT` command to load data from csv Files to bronze tables.<br><br>Parameters:<br>    None. <br>   This stored procedure does not accept any parameters or return any values.<br><br>Usage Example:<br>    EXEC bronze.load_bronze;<br>===============================================================================<br>*/<br><br>-- Execute Stored Procedure<br>EXECUTE bronze.load_bronze;<br><br><br><br>-- Create Stored Procedure<br>CREATE OR ALTER PROCEDURE bronze.load_bronze AS<br>BEGIN<br><br><br>-- bronze.academy<br>TRUNCATE TABLE bronze.academy;<br>BULK INSERT bronze.academy<br>FROM &#39;C:\Users\chavezk\Desktop\SQL\films-dataset\dataset\academy.csv&#39;<br>WITH (<br> FIRSTROW = 2,<br> FORMAT = &#39;CSV&#39;,<br> TABLOCK<br>);<br><br><br>-- bronze.box_office<br>TRUNCATE TABLE bronze.box_office;<br>BULK INSERT bronze.box_office<br>FROM &#39;C:\Users\chavezk\Desktop\SQL\films-dataset\dataset\box_office.csv&#39;<br>WITH (<br> FIRSTROW = 2,<br> FORMAT = &#39;CSV&#39;,<br> TABLOCK<br>);<br><br><br>-- bronze.genres<br>TRUNCATE TABLE bronze.genres;<br>BULK INSERT bronze.genres<br>FROM &#39;C:\Users\chavezk\Desktop\SQL\films-dataset\dataset\genres.csv&#39;<br>WITH (<br> FIRSTROW = 2,<br> FORMAT = &#39;CSV&#39;,<br> TABLOCK<br>);<br><br><br>-- bronze.pixar_films<br>TRUNCATE TABLE bronze.pixar_films;<br>BULK INSERT bronze.pixar_films<br>FROM &#39;C:\Users\chavezk\Desktop\SQL\films-dataset\dataset\pixar_films.csv&#39;<br>WITH (<br> FIRSTROW = 2,<br> FORMAT = &#39;CSV&#39;,<br> TABLOCK<br>);<br><br><br>-- bronze.pixar_people<br>TRUNCATE TABLE bronze.pixar_people;<br>BULK INSERT bronze.pixar_people<br>FROM &#39;C:\Users\chavezk\Desktop\SQL\films-dataset\dataset\pixar_people.csv&#39;<br>WITH (<br> FIRSTROW = 2,<br> FORMAT = &#39;CSV&#39;,<br> TABLOCK<br>);<br><br><br>-- pixar.public_response<br>TRUNCATE TABLE bronze.public_response;<br>BULK INSERT bronze.public_response<br>FROM &#39;C:\Users\chavezk\Desktop\SQL\films-dataset\dataset\public_response.csv&#39;<br>WITH (<br> FIRSTROW = 2,<br> FORMAT = &#39;CSV&#39;,<br> TABLOCK<br>);<br><br>END</pre><h3>3.0 Create Silver Layer ⬜</h3><p>In this layer, this is where we do the data transformations (ETL).</p><p>Within the Silver layer, we will need to make sure the data has the correct:</p><ul><li>Business Requirment/s</li><li>Data Normalization</li></ul><h4>3.1 Create DDL for tables</h4><pre>/*<br>===============================================================================<br>DDL Script: Create Silver Tables<br>===============================================================================<br>Script Purpose:<br>    This script creates tables in the &#39;silver&#39; schema, dropping existing tables <br>    if they already exist.<br>   Run this script to re-define the DDL structure of &#39;bronze&#39; Tables<br>===============================================================================<br>*/<br><br>IF OBJECT_ID(&#39;silver.academy&#39;, &#39;U&#39;) IS NOT NULL<br>    DROP TABLE silver.academy;<br>GO<br><br>CREATE TABLE silver.academy (<br>    film             NVARCHAR(50),<br>    award_type   NVARCHAR(50),<br>    status    NVARCHAR(50)<br>);<br>GO<br><br><br>IF OBJECT_ID(&#39;silver.box_office&#39;, &#39;U&#39;) IS NOT NULL<br>    DROP TABLE silver.box_office;<br>GO<br><br>CREATE TABLE silver.box_office (<br>    film     NVARCHAR(50),<br>    budget     INT,<br>    box_office_us_canada INT,<br>    box_office_other  INT,<br>    box_office_worldwide INT<br>);<br>GO<br><br><br>IF OBJECT_ID(&#39;silver.genres&#39;, &#39;U&#39;) IS NOT NULL<br>    DROP TABLE silver.genres;<br>GO<br><br>CREATE TABLE silver.genres (<br>    film     NVARCHAR(50),<br>    category    NVARCHAR(50),<br>    genre_value    NVARCHAR(50)<br>);<br>GO<br><br><br>IF OBJECT_ID(&#39;silver.pixar_films&#39;, &#39;U&#39;) IS NOT NULL<br>    DROP TABLE silver.pixar_films;<br>GO<br><br>CREATE TABLE silver.pixar_films (<br>    film    NVARCHAR(50),<br>    release_date  DATE,<br>    run_time   INT,<br>    converted_runtime NVARCHAR(50),<br>    film_rating   NVARCHAR(50),<br>    plot    NVARCHAR(255)<br>);<br>GO<br><br><br>IF OBJECT_ID(&#39;silver.pixar_people&#39;, &#39;U&#39;) IS NOT NULL<br>    DROP TABLE silver.pixar_people;<br>GO<br><br>CREATE TABLE silver.pixar_people (<br>    film    NVARCHAR(50),<br>    role_type   NVARCHAR(50),<br>    person_name   NVARCHAR(50)<br>);<br>GO<br><br><br>IF OBJECT_ID(&#39;silver.public_response&#39;, &#39;U&#39;) IS NOT NULL<br>    DROP TABLE silver.public_response;<br>GO<br><br>CREATE TABLE silver.public_response (<br>    film     NVARCHAR(50),<br>    rotten_tomatoes_score INT,<br>    rotten_tomatoes_counts INT,<br>    metacritic_score  INT,<br>    metacritic_counts  INT,<br>    cinema_score   NVARCHAR(50),<br>    imdb_score    FLOAT,<br>    imdb_counts    INT<br>);<br>GO</pre><h4>3.2 Bulk loading the dataset + Create Stored Procedure</h4><pre>/*<br>===============================================================================<br>Stored Procedure: Load Silver Layer (Bronze -&gt; Silver)<br>===============================================================================<br>Script Purpose:<br>    This stored procedure performs the ETL (Extract, Transform, Load) process to <br>    populate the &#39;silver&#39; schema tables from the &#39;bronze&#39; schema.<br> Actions Performed:<br>  - Truncates Silver tables.<br>  - Inserts transformed and cleansed data from Bronze into Silver tables.<br>  <br>Parameters:<br>    None. <br>   This stored procedure does not accept any parameters or return any values.<br><br>Usage Example:<br>    EXEC Silver.load_silver;<br>===============================================================================<br>*/<br><br>-- Execute Stored Procedure<br>EXECUTE silver.load_silver;<br><br><br>-- Create Stored Procedure<br>CREATE OR ALTER PROCEDURE silver.load_silver AS <br>BEGIN<br><br><br>-- silver.academy <br> PRINT &#39;&gt;&gt; Truncating Table: silver.academy&#39;;<br> TRUNCATE TABLE silver.academy;<br> PRINT &#39;&gt;&gt; Inserting Data Into: silver.academy&#39;;<br> INSERT INTO silver.academy(<br>  film, <br>  award_type,<br>  status<br> )<br> SELECT *<br> FROM bronze.academy;<br><br><br>-- silver.genres<br> PRINT &#39;&gt;&gt; Truncating Table: silver.genres&#39;;<br> TRUNCATE TABLE silver.genres;<br> PRINT &#39;&gt;&gt; Inserting Data Into: silver.genres&#39;;<br> INSERT INTO silver.genres(<br>  film, <br>  category,<br>  genre_value<br> )<br> SELECT *<br> FROM bronze.genres;<br><br><br>-- silver.pixar_people<br> PRINT &#39;&gt;&gt; Truncating Table: silver.pixar_people&#39;;<br> TRUNCATE TABLE silver.pixar_people;<br> PRINT &#39;&gt;&gt; Inserting Data Into: silver.pixar_people&#39;;<br> INSERT INTO silver.pixar_people(<br>  film, <br>  role_type,<br>  person_name<br> )<br> SELECT *<br> FROM bronze.pixar_people;<br><br><br>-- silver.box_office<br> PRINT &#39;&gt;&gt; Truncating Table: silver.box_office&#39;;<br> TRUNCATE TABLE silver.box_office;<br> PRINT &#39;&gt;&gt; Inserting Data Into: silver.box_office&#39;;<br> INSERT INTO silver.box_office(<br>  film, <br>  budget,<br>  box_office_us_canada,<br>  box_office_other, <br>  box_office_worldwide<br> )<br> SELECT *<br> FROM bronze.box_office;<br><br>-- silver.public_response<br> PRINT &#39;&gt;&gt; Truncating Table: silver.public_response&#39;;<br> TRUNCATE TABLE silver.public_response;<br> PRINT &#39;&gt;&gt; Inserting Data Into: silver.public_response&#39;;<br> INSERT INTO silver.public_response(<br>  film, <br>  rotten_tomatoes_score,<br>  rotten_tomatoes_counts,<br>  metacritic_score, <br>  metacritic_counts,<br>  cinema_score, <br>  imdb_score,<br>  imdb_counts<br> )<br> SELECT *<br> FROM bronze.public_response<br> ORDER BY rotten_tomatoes_score DESC;<br><br>-- silver.pixar_films<br> PRINT &#39;&gt;&gt; Truncating Table: silver.pixar_films&#39;;<br> TRUNCATE TABLE silver.pixar_films;<br> PRINT &#39;&gt;&gt; Inserting Data Into: silver.pixar_films&#39;;<br> INSERT INTO silver.pixar_films(<br>  film, <br>  release_date, <br>  run_time,<br>  converted_runtime,<br>  film_rating,<br>  plot<br> )<br> SELECT<br>  film, <br>  release_date, <br>  run_time,<br>  CAST ((run_time/60) AS VARCHAR(8)) + &#39;hr &#39; <br>  + RIGHT(&#39;0&#39; + CAST((run_time % 60) AS VARCHAR(2)), 2)<br>  + &#39;min&#39; AS converted_runtime,<br>  film_rating,<br>  plot<br> FROM bronze.pixar_films;<br><br>END<br></pre><h4>3.3 Stored Procedure</h4><p>For any changes made to either the Bronze or Silver layer, in order for the changes to flow — you will need to execute the stored procedure below.</p><p>⚠️<strong><em>Note</em></strong><em>: </em>You will only need to run the stored procedure if <strong>there are no new tables add</strong>.</p><p>In cases where there is a new table to add from the Bronze or Silver layer, you will need to adjust both <em>DDL </em>and <em>LOAD </em>script on the Silver layer.</p><pre>-- Execute Stored Procedure<br>EXECUTE bronze.load_bronze;<br><br>-- Execute Stored Procedure<br>EXECUTE silver.load_silver;</pre><h3>4.0 Create Gold Layer 🟨</h3><p>Once the Silver layer has been established, the final step is to create Business-Ready Data a.k.a the Gold layer.</p><h4>4.1 Table Schema</h4><p>Below is a schema of the Gold table where all columns are the final transformed result from the silver table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*SDeLFBmMW3qM1HCzNfzgoQ.png" /></figure><h4>4.2 Create DDL for tables</h4><pre>/*<br>===============================================================================<br>DDL Script: Create Gold Views<br>===============================================================================<br>Script Purpose:<br>    This script creates views for the Gold layer in the data warehouse. <br>    The Gold layer represents the final dimension and fact tables (Star Schema)<br><br>    Each view performs transformations and combines data from the Silver layer <br>    to produce a clean, enriched, and business-ready dataset.<br><br>Usage:<br>    - These views can be queried directly for analytics and reporting.<br>===============================================================================<br>*/<br><br>-- =============================================================================<br>-- Create Dimension: gold.dim_film<br>-- =============================================================================<br>IF OBJECT_ID(&#39;gold.dim_film&#39;, &#39;V&#39;) IS NOT NULL<br> DROP VIEW gold.dim_film;<br>GO<br><br>CREATE VIEW gold.dim_film AS<br>SELECT<br> a.film   AS Film,<br> pf.release_date AS Release_Date,<br> a.award_type AS Award_Type,<br> a.Status  AS Award_Status,<br> g.category  AS Category,<br> g.genre_value AS Genre,<br> pp.role_type AS Film_Role,<br> pp.person_name AS Name,<br> pf.plot   AS Plot<br>FROM silver.academy a<br> LEFT JOIN silver.genres g ON a.film = g.film<br> LEFT JOIN silver.pixar_people pp ON a.film = pp.film<br> LEFT JOIN silver.pixar_films pf ON a.film = pf.film<br>GO<br><br><br>-- =============================================================================<br>-- Create Dimension: gold.dim_metrics<br>-- =============================================================================<br>IF OBJECT_ID(&#39;gold.dim_metrics&#39;, &#39;V&#39;) IS NOT NULL<br> DROP VIEW gold.dim_metrics;<br>GO<br><br>CREATE VIEW gold.dim_metrics AS<br>SELECT<br> pf.film      AS Film,<br> pf.release_date    AS Release_Date,<br> pf.run_time     AS Run_Time,<br> pf.converted_runtime  AS Converted_Run_Time,<br> bo.budget     AS Budget, <br> bo.box_office_us_canada  AS Box_Office_CA,<br> bo.box_office_other   AS Box_Office_Other, <br> bo.box_office_worldwide  AS Box_Office_Worldwide,<br> pr.rotten_tomatoes_score AS Rotten_Tomatoes_Score,<br> pr.rotten_tomatoes_counts AS Rotten_Tomatoes_Count,<br> pr.metacritic_score   AS Metcritic_Score,<br> pr.metacritic_counts  AS Metcritic_Count,<br> pr.cinema_score    AS Cinema_Score,<br> pr.imdb_score    AS IMDB_Score,<br> pr.imdb_counts    AS IMDB_Count<br>FROM silver.pixar_films pf<br> LEFT JOIN silver.box_office bo ON pf.film = bo.film<br> LEFT JOIN silver.public_response pr ON pf.film = pr.film<br>GO</pre><h3>What now? ❓</h3><p>🎊🎉Well done!🎉🎊</p><p>You have successfully, created a Business-Ready Report that you can send out to the required team! (woohoo!)</p><p>What’s left?</p><p>Continue to build a robust and solid Data Warehouse to accompany changes/updates made to the current dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*Bbbo8KltcVZwBQCAy9XSpg.png" /></figure><h4>References:</h4><ul><li><a href="https://www.youtube.com/watch?v=9GVqKuTVANE&amp;list=PLHpdSsDL8VgsFgK1foT_H0ryuP99Mot1d&amp;index=21">SQL Data Warehouse from Scratch — Data with Baara</a></li><li><a href="https://www.kaggle.com/datasets/willianoliveiragibin/pixar-films">Pixar Film Dataset</a></li><li><a href="https://www.databricks.com/glossary/medallion-architecture"><em>Medallion Architecture</em></a></li><li>Github: <a href="https://github.com/whosthatfilo/sql-pixar-films">https://github.com/whosthatfilo/sql-pixar-films</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5f8699ef9df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running SQL scripts in Python]]></title>
            <link>https://towardsdev.com/running-sql-scripts-in-python-9caa4d90efa9?source=rss-123c42e7f641------2</link>
            <guid isPermaLink="false">https://medium.com/p/9caa4d90efa9</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pyodbc]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Kris Chavez]]></dc:creator>
            <pubDate>Thu, 01 May 2025 05:01:41 GMT</pubDate>
            <atom:updated>2026-05-19T08:13:07.677Z</atom:updated>
            <content:encoded><![CDATA[<h4>using pyodbc package</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*8haZty-ij9cnvPU5mXQ-kw.gif" /></figure><h3>Objective:</h3><p>Use Python to execute and run SQL queries from the desired database.</p><h3>Overview:</h3><p>PYODBC is an open source Python module that makes accessing ODBC databases simple.</p><p>In this blog, we will be using the <strong>pyodbc<em> </em></strong>package in Python to connect to our SQL Server and run/execute SQL queries.</p><p>To simplify the PYODBC process in Python:</p><ol><li><strong>Start</strong> the server connection</li><li><strong>Execute </strong>the changes</li><li><strong>Commit </strong>the changes</li><li><strong>Close </strong>the server connection</li></ol><h3><strong>Architectural Diagram</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*EDHBNyVMjFJDqjr5Cp1_zQ.jpeg" /><figcaption><em>Process diagram (image by author)</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*fugWoSocg2HY7nnQcUdN6Q.jpeg" /><figcaption>User Flow Diagram (image by author)</figcaption></figure><h3>Pre-requisites</h3><ul><li>Must have an SQL Server already setup</li><li>Must have an existing Database in SQL</li><li>Must have Python installed</li><li>(Optional) have Jupyter Notebook installed in Python</li></ul><h3>Code Structure:</h3><pre>################################################################<br>                    # Start the connection<br>################################################################<br><br>conn = pyodbc.connect(&#39;Driver={ADD OBDC SERVER HERE};&#39;<br>                      &#39;Server=ADD SQL SERVER HERE;&#39;<br>                      &#39;Database=ADD DATABASE NAME HERE;&#39;<br>                      &#39;Trusted_Connection=Yes;&#39;)<br>cursor = conn.cursor()<br><br>################################################################<br>                    # Create Table<br>################################################################<br><br>sql =&#39;&#39;&#39;<br>    ADD SQL QUERY HERE<br>  &#39;&#39;&#39;<br><br>################################################################<br>                    # Execute, Commit &amp; Close changes<br>################################################################<br><br># Execute the changes<br>cursor.execute(sql)<br># Commit the changes<br>conn.commit()<br># Close the connection once done<br>conn.close()</pre><h3>Install the required packages:</h3><pre>import pyodbc<br>import pandas as pd<br>import numpy as np <br>import warnings <br>import sqlite3<br>import pandoc<br><br>warnings.filterwarnings(&quot;ignore&quot;)</pre><pre>## Check available ODBC servers <br><br>#pyodbc.drivers()</pre><h3>Create Table</h3><pre># Start the connection<br>conn = pyodbc.connect(&#39;Driver={SQL Server};&#39;<br>                      &#39;Server=localhost;&#39;<br>                      &#39;Database=krisdb;&#39;<br>                      &#39;Trusted_Connection=Yes;&#39;)<br>cursor = conn.cursor()<br><br># Create Table<br>sql =&#39;&#39;&#39;CREATE TABLE EMPLOYEE(<br>   FIRST_NAME CHAR(20) NOT NULL,<br>   LAST_NAME CHAR(20),<br>   AGE INT,<br>   SEX CHAR(1),<br>   INCOME FLOAT<br>);&#39;&#39;&#39;<br><br># Execute the changes<br>cursor.execute(sql)<br><br># Commit the changes<br>conn.commit()<br><br># Close the connection once done<br>conn.close()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*nZGvbndAw-k_FdUx_L9jwg.png" /><figcaption>Created table (image by author)</figcaption></figure><h3>Insert Data</h3><pre># Start the connection<br>conn = pyodbc.connect(&#39;Driver={SQL Server};&#39;<br>                      &#39;Server=localhost;&#39;<br>                      &#39;Database=PythonSQL;&#39;<br>                      &#39;Trusted_Connection=Yes;&#39;)<br>cursor = conn.cursor()<br><br># Run the insert script<br>sql_insert = &quot;&quot;&quot;<br>            INSERT INTO EMPLOYEE<br>                (FIRST_NAME, LAST_NAME, AGE, INCOME) <br>            VALUES <br>                (&#39;C&#39;,&#39;C&#39;,24,40000),<br>                (&#39;D&#39;,&#39;D&#39;,25,50000)<br>            &quot;&quot;&quot;<br><br><br>cursor.execute(sql_insert) <br>conn.commit()<br>conn.close()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*Nj7IeoI6LIGx-0lf05Q4OA.png" /><figcaption>Insert script results (image by author)</figcaption></figure><h3>Update Data</h3><pre># Start the connection<br>conn = pyodbc.connect(&#39;Driver={SQL Server};&#39;<br>                      &#39;Server=localhost;&#39;<br>                      &#39;Database=PythonSQL;&#39;<br>                      &#39;Trusted_Connection=Yes;&#39;)<br>cursor = conn.cursor()<br><br># Run the Update script<br>sql_update = &quot;&quot;&quot;<br>            UPDATE EMPLOYEE<br>            SET SEX = &#39;M&#39; <br>            WHERE FIRST_NAME = &#39;ABC&#39;<br>            &quot;&quot;&quot;<br><br><br>cursor.execute(sql_update) <br>conn.commit()<br>conn.close()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*Nrqfhj-QkYtjDt7_wlOTag.png" /><figcaption>Update query (image by author)</figcaption></figure><h3>Order By</h3><p>Start the connection:</p><pre># Start the connection<br>conn = pyodbc.connect(&#39;Driver={SQL Server};&#39;<br>                      &#39;Server=localhost;&#39;<br>                      &#39;Database=PythonSQL;&#39;<br>                      &#39;Trusted_Connection=Yes;&#39;)<br>cursor = conn.cursor()</pre><p>Run the Order By script:</p><pre>sql = &quot;&quot;&quot; SELECT * FROM EMPLOYEE ORDER BY AGE &quot;&quot;&quot;<br>cursor.execute(sql)<br>for i in cursor : <br>    print(i)</pre><pre># Ascending order<br>sql = &quot;&quot;&quot; SELECT * FROM EMPLOYEE ORDER BY AGE ASC &quot;&quot;&quot;<br>cursor.execute(sql)<br>for i in cursor : <br>    print(i)</pre><pre># Group By<br>sql = &quot;&quot;&quot; <br>    SELECT SEX, count(1) <br>    FROM EMPLOYEE <br>    GROUP BY SEX <br>    &quot;&quot;&quot;<br>cursor.execute(sql)<br>for i in cursor : <br>    print(i)</pre><p>Close the connection</p><pre># Close the connection<br>conn.close()</pre><h3>Delete Data</h3><pre># Start the connection<br>conn = pyodbc.connect(&#39;Driver={SQL Server};&#39;<br>                      &#39;Server=localhost;&#39;<br>                      &#39;Database=PythonSQL;&#39;<br>                      &#39;Trusted_Connection=Yes;&#39;)<br>cursor = conn.cursor()<br><br># Run DELETE command<br>sql = &quot;&quot;&quot; <br>    DELETE FROM EMPLOYEE<br>    WHERE FIRST_NAME = &#39;A&#39;<br>    &quot;&quot;&quot;<br>cursor.execute(sql)<br><br># View changes in the DB<br>sql = &quot;&quot;&quot;<br>SELECT * <br>FROM EMPLOYEE<br>&quot;&quot;&quot;<br>cursor.execute(sql)<br>for i in cursor:<br>    print(i)<br><br>conn.commit()<br>conn.close()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*-_yd78z_qhOV6ODDDykgtQ.png" /><figcaption>Python: Delete query (image by author)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*Nrqfhj-QkYtjDt7_wlOTag.png" /><figcaption>SQL: Result of running the Delete query (image by author)</figcaption></figure><h3>Drop Table</h3><pre># Start the connection<br>conn = pyodbc.connect(&#39;Driver={SQL Server};&#39;<br>                      &#39;Server=localhost;&#39;<br>                      &#39;Database=PythonSQL;&#39;<br>                      &#39;Trusted_Connection=Yes;&#39;)<br>cursor = conn.cursor()<br><br># Run DROP command<br>sql = &quot;&quot;&quot;<br>    DROP TABLE EMPLOYEE<br>    &quot;&quot;&quot;<br>cursor.execute(sql)<br><br>conn.commit()<br>conn.close()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*7WsvCn8dki7n3i7rAv8puQ.png" /><figcaption>Python: Deleting the table (image by author)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/211/1*DGfxRrvNUnu10eTVpHQbPA.png" /><figcaption>SQL: result of the EMPLOYEE table being dropped</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9caa4d90efa9" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/running-sql-scripts-in-python-9caa4d90efa9">Running SQL scripts in Python</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Crypto Currency Data Analysis using Python, SQL and R]]></title>
            <link>https://towardsdev.com/crypto-currency-analysis-e517d6f4eff9?source=rss-123c42e7f641------2</link>
            <guid isPermaLink="false">https://medium.com/p/e517d6f4eff9</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[r]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[crypto]]></category>
            <dc:creator><![CDATA[Kris Chavez]]></dc:creator>
            <pubDate>Tue, 29 Apr 2025 02:45:06 GMT</pubDate>
            <atom:updated>2025-05-26T16:16:38.295Z</atom:updated>
            <content:encoded><![CDATA[<h4>Exploring Crypto Trends Through Data Analysis Techniques</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*WayVmxHVH4OLi4zNf32yIw.gif" /></figure><h3><strong>Objective: 🎯</strong></h3><p>Gather, display and analyze crypto currency data in realtime by using various tools to assist our findings.</p><p>The goal of this blog is to explore ways to:<br>1. Retreive<br>2. Gather<br>3. Analyse crypto data</p><h3><strong>Overview: 📝</strong></h3><p>This project is split into 3 sections.</p><ol><li>Python (RestAPI &amp; ETL)</li><li>SQL (Data Analysis)</li><li>R (Data Analysis &amp; Visualizations)</li></ol><h3>Table of contents:</h3><ul><li><a href="#2f79">Objective</a></li><li><a href="#022f">Overview</a></li><li><a href="#293f">Architectural Diagram</a></li><li><a href="#305c">Approach</a></li><li><a href="#eb74">Pre-requisites</a></li><li><a href="#4fe0">1.0 Data Source: REST API</a></li><li><a href="#262a">1.1 Setup: Normalize Data from JSON to CSV</a></li><li><a href="#189d">1.2 What to do if you get an API rate limit error?</a></li><li><a href="#2ae9">1.3 Steps to fix</a></li><li><a href="#2bcd">1.4 Convert Dataframe to CSV</a></li><li><a href="#18df">1.4.1 Normalize and create Dataframe</a></li><li><a href="#bb42">1.5 Push Data frame to CSV</a></li><li><a href="#85e4">1.5.1 Create the CSV</a></li><li><a href="#4bbc">1.5.2 View the CSV</a></li><li><a href="#4a55">2.0 Import created CSV to SQL Server</a></li><li><a href="#0ee6">2.1 Steps to follow</a></li><li><a href="#d9aa">3.0 Crypto Analysis in R</a></li><li><a href="#cd84">3.1 Pre-requisites</a></li><li><a href="#6a6e">3.2 Data Cleaning Process</a></li><li><a href="#0214">3.2.1 Gather data</a></li><li><a href="#05a6">3.2.2 Remove missing values (NA’s)</a></li><li><a href="#ce05">3.2.3 Parse the required columns</a></li><li><a href="#6d3c">4.0 Main Findings</a></li><li><a href="#8bed">4.1 Best performing cryptocurrencies</a></li><li><a href="#1419">4.2 Bitcoin (BTC) — 24hr change</a></li><li><a href="#f7c9">4.3 Scatterplot: Bitcoin (BTC) — Linear Regression Model</a></li><li><a href="#0d05">4.4 Ethereum (ETH) — 24hr change</a></li></ul><h3><strong>Architectural Diagram:</strong> 🏛️</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8PmWLFELW5Jh_yC3FqzJtg.png" /><figcaption>Crypto Project architectural diagram (image by author)</figcaption></figure><h3><strong>Approach:</strong></h3><ul><li>Retrieve the API data from <a href="https://coinmarketcap.com/"><strong>Coin Market Cap</strong></a><strong><br>(Note: </strong>you must create a free account to access the Crypto API data<strong>)</strong></li><li>Export the API data as a CSV</li><li>Run further analysis on Crypto currencies in SQL and R</li></ul><h3>Pre-requisites:</h3><ul><li>Have an existing developer account in Coin Market Cap (it’s free until a certain amount of API usage)</li><li>SQL server must be installed</li><li>Must have an existing SQL Database already setup</li></ul><h3><strong>1.0 Data Source: REST API 🌐</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*Hlfas8O41gmitSxiwU_Wfw.png" /><figcaption>Python: RestAPI configuration (image by author)</figcaption></figure><h3><strong>1.1 Setup: Normalize Data from JSON to CSV 🐍</strong></h3><p>Below is the code used to:</p><ul><li>Setup your API connection</li><li>Currency converted to AUD</li><li>API limit of <strong>5000 </strong>call requests <br>(<strong>Note</strong>: Free account version is limited to 11 data endpoints, 10k call credits/month, no historical data, for personal use)</li></ul><pre>from requests import Request, Session<br>from requests.exceptions import ConnectionError, Timeout, TooManyRedirects<br>import json<br><br>url = &#39;https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest&#39;<br>parameters = {<br>  &#39;start&#39;:&#39;1&#39;,<br>  &#39;limit&#39;:&#39;5000&#39;,<br>  &#39;convert&#39;:&#39;AUD&#39;<br>}<br>headers = {<br>  &#39;Accepts&#39;: &#39;application/json&#39;,<br>  &#39;X-CMC_PRO_API_KEY&#39;: &#39;[ADD YOUR API KEY HERE]&#39;,<br>}<br><br>session = Session()<br>session.headers.update(headers)<br><br>try:<br>  response = session.get(url, params=parameters)<br>  data = json.loads(response.text)<br>  print(data)<br>except (ConnectionError, Timeout, TooManyRedirects) as e:<br>  print(e)</pre><h3><strong>1.2 What to do if you get an API rate limit error? 🐍</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*qlWKheaTE33STHo5QFHY7w.png" /></figure><h3>1.3 Steps to fix: 🐍</h3><ol><li>Open CMD as an Admin</li><li>Type in jupyter notebook --generate-config</li><li>Locate and open the <strong>jupyter_server_config.py </strong>file</li><li>Filter CNTRL + F and search for <strong>‘iopub_data_rate_limit’</strong></li><li>Take out the comment (#) and edit the Rate limit ie. 200000</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*e303g88tC-uv-imhSOlueA.png" /><figcaption>Jupyter Server config script (image by author)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*0LxwIpLgH0PwPQvZNzjv6A.png" /><figcaption>Change iopub_data_rate_limit (image by author)</figcaption></figure><h3>1.4 Convert Dataframe to CSV 🐍</h3><h3>1.4.1 Normalize and create Dataframe 🐍</h3><pre>import pandas as pd<br>import csv<br><br>pd.set_option(&#39;display.max_columns&#39;, None)<br><br>df = pd.json_normalize(data[&#39;data&#39;])<br><br>df.head()</pre><pre># replace NaN values -&gt; with 0<br>coin_clean_df = df.fillna(0)<br>print(coin_clean_df)<br><br>#coin_clean_2.head()</pre><h3>1.5 Push Data frame to CSV 🐍</h3><h3>1.5.1 Create the CSV 🐍</h3><pre># With Headers<br>coin_clean_df.to_csv(r&#39;C:\Users\chavezk\Desktop\Python\Crypto_Project\api_data_cleaned.csv&#39;, index=0) # no index column<br><br># Without Headers<br>#coin_clean_df.to_csv(r&#39;C:\Users\chavezk\Desktop\Python\Get_API_Data\api_data_no_headers.csv&#39;, header=0, index=0) # no index column</pre><h3>1.5.2 View the CSV 🐍</h3><pre>## view CSV file<br>coin_clean_df = pd.read_csv(r&#39;C:\Users\chavezk\Desktop\Python\Crypto_Project\api_data_cleaned.csv&#39;) # no index column<br>coin_clean_df.head(3)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*jIt8S1IAeYEBts-yNfqLgA.png" /><figcaption>Created CSV file (image by author)</figcaption></figure><h3>2.0 Import created CSV to SQL Server 🪅</h3><p><strong>Purpose: </strong>To maintain the simplicity of this blog, I only mentioned how to upload the created CSV file <strong>into </strong>SQL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/273/1*DWjJXUvIr7rfkl9LEpo2rA.png" /><figcaption>SQL: Import file process (image by author)</figcaption></figure><h3><strong>2.1 Steps to follow: 🪅</strong></h3><ol><li>Create a new database</li><li>Right-click on the database &gt; Tasks &gt; Import flat file…</li><li>Next</li><li>Browse &gt; Search and select the crypto CSV file</li><li>Next</li><li><strong>Untick </strong>“Use Rich Data Type Detection…”</li><li>Next</li><li>Tick <strong>Primary Key checkbox</strong> for <strong>ID</strong> column</li><li>Make sure all other column data type is correct (screenshot below)</li><li>Next</li><li>Finish</li><li>Close</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*qDMielwH8R-ZU_WxmiCg2A.png" /><figcaption>Import flat file (image by author)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*TAEysOhvoXl6IR6UO1RXAw.png" /><figcaption>Untick “Use Rich data Type Detection” (image by author)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*ApaL041He-k-eDavJRg5ng.png" /><figcaption>Import flat file (image by author)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/1*nrh2DacNVK4A5vKYCSUt7Q.png" /><figcaption>Newly imported table (image by author)</figcaption></figure><h3>3.0 Crypto Analysis in R 📊</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*FiUz9XA07jT69SnRJ5jXYA.png" /><figcaption>R: Crypto analysis diagram (image by author)</figcaption></figure><h3>3.1 Pre-requisites 📊</h3><p>(installing the required packages + creating the data frame)</p><pre># install.packages(&quot;tidyverse&quot;)<br># install.packages(&quot;lubridate&quot;)<br># install.packages(&quot;scales&quot;)<br># install.packages(&quot;fishualize&quot;)<br># install.packages(&quot;extrafont&quot;)<br># install.packages(&quot;randomForest&quot;)<br># install.packages(&quot;dplyr&quot;)<br># install.packages(&quot;tidyr&quot;)<br># install.packages(&quot;readxl&quot;)<br># install.packages(&quot;Hmisc&quot;)<br># install.packages(&quot;ggplot2&quot;)<br># install.packages(&quot;reshape2&quot;)<br># install.packages(&quot;lattice&quot;)<br># install.packages(&quot;readr&quot;)<br># install.packages(&quot;time&quot;)<br># install.packages(&quot;datetime&quot;)<br># install.packages(&quot;ggthemes&quot;)<br># install.packages(&quot;lubridate&quot;)<br># install.packages(&quot;plotly&quot;)<br># install.packages(&quot;stats&quot;)<br>#install.packages(&quot;janitor&quot;)<br><br>library(tidyverse)<br>library(lubridate)<br>library(scales)<br>library(fishualize)<br>library(extrafont)<br>library(randomForest)<br>library(dplyr)<br>library(tidyr)<br>library(readxl)<br>library(Hmisc)<br>library(ggplot2)<br>library(reshape2)<br>library(lattice)<br>library(readr)<br>library(datetime)<br>library(ggthemes)<br>library(lubridate)<br>library(plotly)<br>library(stats)<br>library(janitor)<br><br><br># Remove scientific notation<br>options(scipen = 999)</pre><pre># Create Dataframe<br>crypto &lt;- read.csv(&quot;api_data_cleaned.csv&quot;)</pre><h3>3.2 Data Cleaning Process 📊</h3><h3>3.2.1 Gather data 📊</h3><pre># Convert columns to numeric<br><br># Gather the required tables used for analysis<br>numeric_df &lt;- crypto %&gt;%<br>  select(num_market_pairs,<br>         max_supply,<br>         circulating_supply,<br>         total_supply,<br>         self_reported_circulating_supply,<br>         self_reported_market_cap,<br>         quote.AUD.price,<br>         quote.AUD.volume_24h,<br>         quote.AUD.volume_change_24h,<br>         quote.AUD.percent_change_1h,<br>         quote.AUD.percent_change_24h,<br>         quote.AUD.percent_change_7d,<br>         quote.AUD.percent_change_30d,<br>         quote.AUD.percent_change_60d,<br>         quote.AUD.percent_change_90d,<br>         quote.AUD.market_cap,<br>         quote.AUD.market_cap_dominance,<br>         quote.AUD.fully_diluted_market_cap,<br>         platform.name,<br>         platform.symbol)<br>#numeric_df</pre><h3>3.2.2 Remove missing values (NA’s) 📊</h3><pre># Omit (remove) all missing values<br>#numeric_new &lt;- na.omit(numeric_df)<br><br># Get NA values<br>#is.na(numeric_new)<br><br># Check NA value count<br>#sum(is.na(numeric_new))</pre><h3>3.2.3 Parse the required columns 📊</h3><p><strong>Purpose:</strong></p><ul><li>Parse = “breakdown” of Character vectors &gt; turning it into a expression (ie. Numerical class)</li><li>Change class type from ‘CHARACTER’ to ‘NUMERICAL’</li><li>This is required to do statistical calculations</li></ul><pre># Use parse_number (readr package) <br># to parse (breakdown) the &#39;.&#39; and &#39;,&#39; on the numbers<br># reason: convert all &#39;.&#39; and &#39;,&#39; to numeric values<br><br>numeric_new &lt;- numeric_df<br><br>numeric_new$num_market_pairs &lt;- parse_number(numeric_new$num_market_pairs, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$max_supply &lt;- parse_number(numeric_new$max_supply, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$circulating_supply &lt;- parse_number(numeric_new$circulating_supply, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$total_supply &lt;- parse_number(numeric_new$total_supply, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$self_reported_circulating_supply &lt;- parse_number(numeric_new$self_reported_circulating_supply, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$self_reported_market_cap &lt;- parse_number(numeric_new$self_reported_market_cap, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$quote.AUD.price &lt;- parse_number(numeric_new$quote.AUD.price, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$quote.AUD.volume_24h &lt;- parse_number(numeric_new$quote.AUD.volume_24h, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$quote.AUD.volume_change_24h &lt;- parse_number(numeric_new$quote.AUD.volume_change_24h, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>#numeric_new$quote.AUD.percent_change_1h &lt;- parse_number(numeric_new$quote.AUD.percent_change_1h, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$quote.AUD.percent_change_24h &lt;- parse_number(numeric_new$quote.AUD.percent_change_24h, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$quote.AUD.percent_change_7d &lt;- parse_number(numeric_new$quote.AUD.percent_change_7d, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$quote.AUD.percent_change_30d &lt;- parse_number(numeric_new$quote.AUD.percent_change_30d, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$quote.AUD.percent_change_60d &lt;- parse_number(numeric_new$quote.AUD.percent_change_60d, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$quote.AUD.percent_change_90d &lt;- parse_number(numeric_new$quote.AUD.percent_change_90d, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$quote.AUD.market_cap &lt;- parse_number(numeric_new$quote.AUD.market_cap, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>#numeric_new$quote.AUD.market_cap_dominance &lt;- parse_number(numeric_new$quote.AUD.market_cap_dominance, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>numeric_new$quote.AUD.fully_diluted_market_cap &lt;- parse_number(numeric_new$quote.AUD.fully_diluted_market_cap, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br><br># View classes after change<br>str(numeric_new)</pre><h3>4.0 Main Findings: 📊</h3><h3>4.1 Best performing cryptocurrencies 📊</h3><ul><li>BTC is rank #1 whilst ETH being #2 and following is USDT as #3</li><li>Y-axis = Market Dominance</li><li>X-axis = Crypto Currency</li></ul><pre># Get the top 10 best performing Cryptocurrencies<br>top_10 &lt;- crypto %&gt;%<br>  select(name, symbol, quote.AUD.market_cap_dominance) %&gt;%<br>  count(name, symbol, quote.AUD.market_cap_dominance) %&gt;%<br>  arrange(desc(quote.AUD.market_cap_dominance)) %&gt;%<br>  slice(1:10) %&gt;%<br>  arrange(-quote.AUD.market_cap_dominance) %&gt;% #ascending order<br>  mutate(symbol = factor(symbol, levels = symbol))<br><br># Visualize the data via. Barplots<br>ggplot(data = top_10,aes(x = symbol, y = quote.AUD.market_cap_dominance, fill = symbol)) +<br>  geom_text(aes(label = quote.AUD.market_cap_dominance), size =2, vjust = -0.3) +<br>  theme_classic() + <br>  scale_fill_viridis_d() +<br>  geom_bar(stat = &quot;identity&quot;) +<br>  labs(title = &quot;Top 10 best performing Cryptocurrencies&quot;,<br>       x = &quot;Symbols&quot;,<br>       y = &quot;Market Cap Dominance&quot;) +<br>  labs(subtitle = &quot;Shown in descending order of number of models&quot;)<br>ggsave(filename = &quot;top_10_crypto.png&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lKQy5c-1gg7WfQfqlhMZgw.png" /><figcaption>Top 10 best performing Cryptocurrencies (image by author)</figcaption></figure><h3>4.2 Bitcoin (BTC) — 24hr change 📊</h3><ul><li>Main focus is BTC as this is has the highest market cap dominance</li><li>View the volume change from the years of 2023–2025</li><li>As shown on the graph below, BTC performed the best between the dates of <strong>2024–01 to 2024–07</strong></li></ul><pre># filter Bitcoin values only <br>btc &lt;- filter(crypto, platform.symbol == &quot;BTC&quot;)<br><br># parse date columns from CHARACTER to DATE<br>btc$date_added &lt;- as.POSIXct(btc$date_added, format = &quot;%Y-%m-%dT%H:%M:%OSZ&quot;, tz = &quot;UTC&quot;)<br>btc$date_added &lt;- as.Date(btc$date_added)<br><br># parse the columns from Character to numeric<br>btc$quote.AUD.volume_24h &lt;- parse_number(btc$quote.AUD.volume_24h, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>btc$quote.AUD.volume_change_24h &lt;- parse_number(btc$quote.AUD.volume_change_24h, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>btc$total_supply &lt;- parse_number(btc$total_supply, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br><br># parse date columns from CHARACTER to DATE<br>btc$date_added &lt;- as.POSIXct(btc$date_added, format = &quot;%Y-%m-%dT%H:%M:%OSZ&quot;, tz = &quot;UTC&quot;)<br>btc$date_added &lt;- as.Date(btc$date_added)<br><br># Present data as Geom Line<br># Label only the top 4 volume changes<br>btc_top_4 &lt;- btc %&gt;% <br>  top_n(4, quote.AUD.volume_change_24h)<br><br>ggplot(btc, aes(x = date_added, y = quote.AUD.volume_change_24h, color = &quot;region&quot;)) +<br>  geom_line(size = 3, alpha = 0.8) +<br>  geom_text(data = btc_top_4,<br>            aes(label = round(quote.AUD.volume_change_24h, 2)), # Round for cleaner labels<br>            size = 3, color = &quot;Black&quot;, vjust = -0.5) +<br>  labs(title = &quot;BTC: 24hr Volume Change from 2023-2025 (Top 4)&quot;,<br>       subtitle = &quot;(Figure in $AUD)&quot;,<br>       x = &quot;Date&quot;,<br>       y = &quot;Volume Change in 24hrs&quot;,<br>       color = &quot;Region&quot;) +<br>  theme_fivethirtyeight() +<br>  theme(axis.title = element_text())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gvO-zOA6M9Kcz8CeLDZfOA.png" /><figcaption>BTC: 24hr Volume Change from 2023–2025 (Top 4) (image by author)</figcaption></figure><h3>4.3 Scatterplot: Bitcoin (BTC) — Linear Regression Model 📊</h3><ul><li>Although it is hardly noticable, there is a slight positive trend with BTC.</li><li>During the last 2 years, the 24hr volume change has continued to increase — suggesting that BTC will continue to have a steady positive trend.</li></ul><pre># Linear Regression model<br>ggplot(<br>  data = btc,<br>  mapping = aes(x = date_added, y = quote.AUD.volume_change_24h, color = &quot;linear regression&quot;)<br>) +<br>  geom_point(mapping = aes(color = &quot;BTC&quot;)) + <br>  geom_smooth(method = &quot;lm&quot;) +<br>  labs(title = &quot;BTC: Linear Regression Model&quot;,<br>       subtitle = &quot;24hr Volume Change from 2023-2025&quot;,<br>       x = &quot;Date&quot;,<br>       y = &quot;Volume Change in 24hrs&quot;,<br>       color = &quot;Region&quot;) +<br>  scale_color_colorblind() +<br>  theme_fivethirtyeight() +<br>  theme(axis.title = element_text())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vnxP0B8NGBPlhYWn_PYiBQ.png" /><figcaption>BTC: Linear Regression Model (image by author)</figcaption></figure><h3>4.4 Ethereum (ETH) — 24hr change 📊</h3><ul><li>As ETH was ranked 2nd on the top 10 best performing cryptocurrencies, I wanted to focus on why ETH was ranked 2nd.</li><li>Even though ETH had a great year around mid to late 2022; where the 24hr change was at a all time high — the following year continued to show a decreasing trend. Suggesting, that ETH performance isn’t as good as BTC.</li><li>To add on, late 2020 to 2021 showed a positive trend.</li><li>And the “big boom” didn’t occur until late 2022</li><li>This suggests that people who invested into ETH from 2021 onwards had a bigger return when compared to those who invested in ETH mid 2022 onwards.</li></ul><pre># filter Bitcoin values only <br>eth &lt;- filter(crypto, platform.symbol == &quot;ETH&quot;)<br><br># parse the columns from Character to numeric<br>eth$quote.AUD.volume_24h &lt;- parse_number(eth$quote.AUD.volume_24h, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>eth$quote.AUD.volume_change_24h &lt;- parse_number(eth$quote.AUD.volume_change_24h, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br>eth$total_supply &lt;- parse_number(eth$total_supply, locale = locale(decimal_mark =&quot;.&quot;, grouping_mark =&quot;,&quot;))<br><br># parse date columns from CHARACTER to DATE<br>eth$date_added &lt;- as.Date(as.POSIXct(eth$date_added, origin = &quot;1970-01-01&quot;, tz = &quot;UTC&quot;))<br><br># Present data as Geom Line<br># Label only the top 4 volume changes<br>top_4_volume &lt;- eth %&gt;%<br>  top_n(4, quote.AUD.volume_change_24h)<br><br>ggplot(eth, aes(x = date_added, y = quote.AUD.volume_change_24h, color = &quot;region&quot;)) +<br>  geom_line(size = 3, alpha = 0.8) +<br>  # Label the top 4 volume change points<br>  geom_text(data = top_4_volume,<br>            aes(label = round(quote.AUD.volume_change_24h, 2)), # Round for cleaner labels<br>            size = 3, color = &quot;Black&quot;, vjust = -0.5) +<br>  labs(title = &quot;ETH: 24hr Volume Change from 2016-2024 (Top 4)&quot;,<br>       subtitle = &quot;(Figure in $AUD)&quot;,<br>       x = &quot;Date&quot;,<br>       y = &quot;Volume Change in 24hrs&quot;,<br>       color = &quot;Region&quot;) +<br>  theme_fivethirtyeight() +<br>  theme(axis.title = element_text())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*opKRdjS8x3UCdqQ3HYyJZA.png" /><figcaption>ETH: 24hr Volume Change from 2016–2024 (Top 4) (image by author)</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e517d6f4eff9" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/crypto-currency-analysis-e517d6f4eff9">Crypto Currency Data Analysis using Python, SQL and R</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>