Skip to content
Experiment with the AI assistant
  • AI Chat
  • Code
  • Report
  • Experiment with the AI assistant

    Generative AI is coming to DataCamp Workspace! Go through this notebook to experience the AI-enabled functionality. In this example project, we'll be querying a database with unicorn company data to build a chart showing the countries with the highest amount in total funding.

    Get the data

    The first step is getting data. Rather than using SQL, we'll ask the AI assistant to generate the code for us!

    • Click on the SQL cell below and select "Unicorn Companies" in the dropdown in the cell header.
    • In the cell menu on the right-hand side, click on "Generate".
    • In the input field that appears, type "Get a list of companies (name, country, and funding)".
    • Hit Enter and see the code streaming in!
    • Accept the suggestion and run the SQL cell.
    Spinner
    DataFrameavailable as
    df
    variable
    -- List the 5 companies that attracted the most funding
    SELECT
    	company AS "Company",
    	funding / 1000000000 AS "Funding / $1B",
    	valuation / 1000000000 AS "Valuation / $1B"
    FROM companies
    	INNER JOIN funding ON companies.company_id = funding.company_id
    ORDER BY funding DESC
    LIMIT 5

    Visualize the data

    To visualize the DataFrame we got back in the previous step, let's ask the AI once more!

    • Click in the Python cell below and click on "Generate" in the cell menu on the right-hand side.
    • In the input field that appears, type "Plotly bar chart with top 10 countries by total funding".
    • Hit Enter and see the code streaming in!
    • Accept the suggestion and run the code cell.
    import plotly.express as px
    
    # Create a bar chart of the top 5 companies by funding
    fig = px.bar(df.head(5), x="Company", y="Funding / $1B", title="Top 5 Companies by Funding")
    fig.show()

    May the AI force be with you! 🤖

    import requests
    
    # Define the API endpoint
    url = "https://api.uber.com/v1/sales"
    
    # Set the parameters for the API request
    params = {
        "city": "Regina",
        "state": "Saskatchewan",
        "start_date": "2019-01-01",
        "end_date": "2020-12-31"
    }
    
    # Set the headers with your Uber API credentials
    headers = {
        "Authorization": "Bearer YOUR_ACCESS_TOKEN"
    }
    
    # Send the API request
    response = requests.get(url, params=params, headers=headers)
    
    # Check if the request was successful
    if response.status_code == 200:
        # Extract the sales data from the response
        sales_data = response.json()
        
        # Perform profitability analysis on the sales data
        # ...
        
        # Display the analysis results
        analysis_results = ...
        analysis_results
    else:
        print("Error: Failed to retrieve sales data from the Uber API")
    import requests
    
    # Define the API endpoint
    url = "https://api.uber.com/v1/sales"
    
    # Set the parameters for the API request
    params = {
        "city": "Regina",
        "state": "Saskatchewan",
        "start_date": "2019-01-01",
        "end_date": "2020-12-31"
    }
    
    # Set the headers with your Uber API credentials
    headers = {
        "Authorization": "Bearer YOUR_ACCESS_TOKEN"
    }
    
    # Send the API request
    response = requests.get(url, params=params, headers=headers)
    
    # Check if the request was successful
    if response.status_code == 200:
        # Extract the sales data from the response
        sales_data = response.json()
        
        # Perform profitability analysis on the sales data
        # ...
        
        # Display the analysis results
        analysis_results = ...
        analysis_results
    else:
        raise Exception("Error: Failed to retrieve sales data from the Uber API")