<?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 Daniel Charles Walusaga on Medium]]></title>
        <description><![CDATA[Stories by Daniel Charles Walusaga on Medium]]></description>
        <link>https://medium.com/@walusagadanielcharles?source=rss-77ce3247c004------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Pka7zUj3-9dAbHR3wtQDvQ.jpeg</url>
            <title>Stories by Daniel Charles Walusaga on Medium</title>
            <link>https://medium.com/@walusagadanielcharles?source=rss-77ce3247c004------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 21:53:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@walusagadanielcharles/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[Data Cleaning: Inspecting and Wrangling the FIFA 21 Data Using Postgresql (PGAdmin 4)]]></title>
            <link>https://medium.com/@walusagadanielcharles/data-cleaning-inspecting-and-wrangling-the-fifa-21-data-using-postgresql-pgadmin-4-bf76abfdce7c?source=rss-77ce3247c004------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf76abfdce7c</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[pgadmin-4]]></category>
            <category><![CDATA[data-cleaning]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Daniel Charles Walusaga]]></dc:creator>
            <pubDate>Wed, 19 Apr 2023 13:28:30 GMT</pubDate>
            <atom:updated>2023-04-19T13:30:05.384Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*tvKA50lF5XKx0Tnn.png" /></figure><p><strong>Background<br></strong>A friend of mine recently referred me to this site to try out the <em>Fifa 21 data cleaning challenge</em> as means to show case my SQL skills. Many of us in the data analyst space understand the structured query language, but how often is it that we get out of our comfort zone to clean up data in a given database? In most jobs this is already done and defined along setup of the database so it is majorly querying and analysing data.In the data analyst space we also know how hectic it is to work with unclean data in a database, so I was curious when I looked at the CSV file containing the Fifa21 data, and asked the question, without the tools provided by the corporate environment in our different jobs, how would I go about this in SQL? I decided to use PGAdmin 4 since I am more acquainted with Postgresql. Let us dig in!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/0*FxmBeqAM9-cRo9TH.png" /></figure><h3><strong>Roadmap</strong></h3><p><strong>a) Creating a data base copy of the CSV file of the dataset in PGAdmin 4<br></strong>First we needed to create a table structure similar to the csv data we want to import.</p><ul><li>Database &gt; schema &gt; public &gt; tables &gt; create</li><li>Give it a name, Under the columns, ensure that its the exact number of columns in the csv file we want to import with the same column names.</li><li>Check the data type for each column and ensure its correct, incase of distorted data, we use character varying as data type.</li><li>Chose a primary key for the data. In this case i choose ID because its a unique identifyer for all players.</li><li>Save the table</li><li>Right click on the table, select Query tool,</li><li>Run the code Copy public.&quot;tablename&quot; from &#39;/csvpath&#39; Delimiter &#39; , &#39; Csv Header ; in order to import the csv file into the table we created.</li></ul><p><strong><em>Errors encountered while trying to import</em></strong></p><ul><li>ERROR could not open file<em> “/Users/danielcharles/Downloads/fifa21_raw_data_v2.csv”</em> for reading: Permission denied.</li></ul><p><strong><em>Solution on MacBook</em></strong></p><ul><li>open /tmp</li><li>or in finder directory you directly enter command+shift+g then type /tmp in go to the folder.</li><li>it opens temp folder in finder. then paste copied csv file into this folder.</li><li>Copy the new file path. (One trick of getting the file path on macs, open terminal, select and drag the file from the folder and drop in the terminal)</li><li>COPY public.&quot;FIFA21&quot; FROM &#39;/private/tmp/fifa21_raw_data_v2.csv&#39; DELIMITER &#39;,&#39; CSV HEADER; (notice the difference in the two paths)</li></ul><p><strong>First look at our data in the database</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tQ9P-ZvCO-VFVzFrxNSoEQ.png" /></figure><p><strong>b) Cleaning up the dataset for further analysis</strong></p><p>This is where things get interesting. We need to ensure the data is neat, accuracy of both the data types and data format.<br>As I scrolled through the data, i noticed inconsistencies in the following columns;<br>• Contract column ( years with special characters)<br>• Height column (mixture of cm and feet)<br>• Weight column (Lbs and Kg)<br>• Value, Wage, Release clause columns (mixture of currency symbol, M for million and K for thousand)<br>• W/F, SM, IR columns(integers mixed up with special characters to represent ratings)<br>• Hits column (Integers mixed up with suffix symbols (k) to represent thousand)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pNboqeX_XQMnvbNAoDVTPg.png" /></figure><p><strong><em>Work around</em></strong></p><p>I had to use subqueries or ctes in order to clean up every the relevant column which i later joined in my final query to extract the clean data.</p><ul><li>Fixing the Contract column ( Mixed up with years, special characters and contract types)<br>I used the following code, with the logic of introducing new columns to split the data. contract start column, contract end column and contract type column.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Irvi11cc58TteJ9NwuWWKA.png" /></figure><ul><li>Fixing the Height column (mixture of cm and feet) and the HITS column<br>I used the following code, with the logic of introducing a new column to Unify the data format in cm.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*64R-dMdLA4IGmFdOF2GhrQ.png" /></figure><ul><li>Fixing the Weight column (Lbs and Kg)<br>I used the following code, with the logic of introducing a new column to Unify the data format in kg.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CLYPr9eVjqYaj9wsXnrbVg.png" /></figure><ul><li>Fixing the columns with the Amounts. That is Value, Wage, Release clause columns (mixture of currency symbol, M for million and K for thousand)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pqW-4qwCBFf_AtxruN485A.png" /></figure><ul><li>Fixing the ratings columns. That is W/F, SM, IR columns(integers mixed up with special characters to represent ratings)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6aLuCEBLd69_TuAtEMeg5A.png" /></figure><p><strong>C) Final Query Output</strong></p><p><strong>i) Cleaned columns</strong><em><br></em>Here is an output look of all the columns we have fixed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UAiWfolIxBD_Ou59n6w0sw.png" /></figure><p><strong>ii) Final output table extract</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V-N_b7Qp34Oad8FKk0uUqA.png" /></figure><p>Once I was done fixing the necessary columns, I used joins to combine all the data and came up with one table with clean data.</p><p><strong>D) Creating a View<br></strong>To save this table in my schema to be used for further analysis, I created a view with the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ER7cl_BVVdX2DvHD8ABoBA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y6iYLlBAo-r-xhwg8fzTlg.png" /></figure><h3><strong>Conclusion</strong></h3><p>I personally enjoyed working on this challenge and I am on the look out for more challenges. Feel free to reach out to me incase you have any questions, I tried to be as brief as possible in this presentation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf76abfdce7c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>