Tag: datapreparation

  • 11. How to Make Sure Your Data Matches Its Description in BigQuery

    #datavalidation #datadescritption #BigQuery

    Based on a hands-on activity of Google Data Analytics Professional issued by Coursera

    File > Download (csv file) the reference table automobile_data

    Create a new data set: open Big Query console, go to the Explorer pane in your workspace to add data

    Create a table (first create a project and a dataset)

    Get an initial understanding of the data table by clicking on the PREVIEW tab

    Enlarged view

    Check the data according to a given data description.

    Requirement 1: the fuel_type column should only have two unique string values: diesel and gas.

    Requirement 2: Length column should range from 141,1 to 208,1.

    Requirement 3: manage null data in the number of doors column.

    Select all lines with a null value in num_of_doors colum with a query

    Update this null value with four (4) with this query:

    Note that Update operation requires a billing account (you can skip). Repeat the same for mazda

    Requirement 4: check potential errors for number of cylinders column

    “tow” in line 7 is a spell-check error. It should be “Two”

    Requirement 5: ensure consistency

    Getting data from a table using SELECT statements.

    De-duplicating data using commands like DISTINCT and COUNT + WHERE.

    Manipulating string data with TRIM to remove extra spaces in a string and SUBSTR to get a portion of a string.

    Creating/dropping tables with CREATE TABLE and DROP TABLE per create or delete tables.

    Changing data types with CAST TO Convert the results of an expression to the given type.

  • 9. How to clean data with Google Sheets functions (part 4): Split data

    #datacleaning #datapreparation #GoogleSheets

    How to split data from the following table with the GPS coordinates of the Colosseum in Rome, Italy to obtain latitude and longitude: insert SPLIT function in a new cell, A4 is the cell where the text is located, “-“ means that the text is divided based on minus sign.

  • 8. How to clean data with Google Sheets functions (part 1): Remove duplicates and COUNTIF functions

    #datacleaning #datapreparation #GoogleSheets

    Step 1: Remove any duplicates

    Select all columns, in the menu bar choose Data, then Data cleanup and select Remove duplicates.

    Click Data has header row andselect the columns where to remove duplicates i.e. column D for names

    Step 2: Clean up any data that does not make sense with COUNTIF function

    The COUNTIF function returns a conditional count across a range.

    Syntax

    COUNTIF(range, criterion)

    • range – The range that is tested against criterion.
    • criterion – The pattern or test to apply to range.

    i.e. COUNTIF(A2:A9, “Taxi”) to see how many Taxi entries are in the table rows A2:A9

  • 7. How to clean data with Google Sheets (part 2): delete extra spaces and change case in strings

    #datacleaning #datapreparation #GoogleSheets

    Further Cleaning data steps continued from the part 1 with the reference table available in https://docs.google.com/spreadsheets/d/1PkAbgXC7C1g2dKzCCpaHBcAyPw-s1z7iUxIEJ0cCYWQ/template/preview

    Step 3: Delete extra spaces in cells with string data

    Highlight the data in the spreadsheet, click on the Data tab, from Data cleanup select Trim whitespaces

    The following message explains that extra spaces were deleted in 4 cells:

    Step 4: Change case (upper and lower) text

    Google Sheets provides an Add-On for this task: click on the Add-ons option at the top of Google Sheets, click on Get add-ons and search for ChangeCase.

    To change the case, select the text to be edited, e.g. a column, click on the Add-Ons tab and select ChangeCase and select the option All lowercase or the needed option

    to obtain all lowercase in the selected column

    This step can be reverted with Clear formatting: click the Format tab and select the Clear Formatting option.

  • 6. How to clean data with Google Sheets: blank cells and transpose (part 1)

    #datacleaning #datapreparation #GoogleSheets

    Data cleaning includes several activities. This example is based on a hands-on activity of Google Data Analytics Professional issued by Coursera.

    Reference file is available here:

    https://docs.google.com/spreadsheets/d/1PkAbgXC7C1g2dKzCCpaHBcAyPw-s1z7iUxIEJ0cCYWQ/template/preview

    Step 1: Find blank cells

    Highlight all cells in the spreadsheet, click on Data e select Create a filter

    To review a list of all the rows with blank cells, in the Order date column Filter by condition (is empty) and click OK:

    After managing these cells, turn off this filter with Filter by condition (None).

    Step 2: Transpose

    Transposing=convert the data from long format (more rows than columns) to wide format (more columns than rows).

    Highlight and copy data to be transposed including column labels (e.g. columns A1-H45). Then select a new cell (J2) and Paste special with Transpose option.

    Delete the old table.