Python Data Science Toolbox (Part 2)
  • AI Chat
  • Code
  • Report
  • Beta
    Spinner

    Python Data Science Toolbox (Part 2)

    👋 Welcome to your new workspace! Here, you can experiment with the data you used in Python Data Science Toolbox (Part 2) and practice your newly learned skills with some challenges. You can find out more about DataCamp Workspace here.

    Below is a code cell that imports the course packages and two datasets as pandas DataFrames.

    🏃To execute the code, click inside the cell to select it and click "Run" or the ► icon. You can also use Shift-Enter to run a selected cell and automatically switch to the next cell.

    # Import the course packages
    import pandas as pd
    import matplotlib.pyplot as plt
    
    # Import the course datasets as DataFrames
    world_ind = pd.read_csv('datasets/world_ind_pop_data.csv')
    tweets = pd.read_csv('datasets/tweets.csv')
    
    # Preview the first DataFrame
    world_ind

    Challenge Yourself

    Don't know where to start? Add code to the code cells below to try one (or more) of the following challenges.

    Reminder: To execute the code you add to a cell, click inside the cell to select it and click "Run" or the ► icon. You can also use Shift-Enter to run a selected cell and automatically switch to the next cell.

    1. Create a zip object containing the CountryName and CountryCode columns in world_ind. Unpack the resulting zip object and print the tuple values.

    # Zip and unpack country names and country codes in world_ind
    

    2. Use a list comprehension to extract the first 25 characters of the text column of the tweets DataFrame provided that the tweet is not a retweet (i.e., starts with "RT").

    # Use list comprehension to print the first 25 characters of tweets
    

    3. Create an iterable reader object so that you can use next() to read datasets/world_ind_pop_data.csv in chunks of 20.

    # Create an interable reader object to read chunks of datasets/world_ind_pop_data.csv
    

    Continue to Explore

    Feeling confident about your skills? If you're following the Data Scientist with Python Career Track, continue to Intermediate Data Visualization with Seaborn! If you're interested in further developing your programming skills, you may be interested in other Python Programmer Career Track courses!