Luis Enrique Quispe Paredes
‌
‌
‌
‌
‌
‌
‌
‌
‌
‌
‌
‌
‌
‌
Sign up
Beta
Spinner

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.
Unknown integration
DataFrameavailable as
df
variable
SELECT company, country, funding
FROM companies
JOIN funding ON companies.company_id = funding.company_id;
This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.

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 matplotlib.pyplot as plt import numpy as np

df = # insert DataFrame from SQL query here top_10 = df.groupby('country')['funding'].sum().nlargest(10).reset_index()

x = np.arange(len(top_10['country'])) y = top_10['funding']

plt.scatter(x, y) plt.plot(np.unique(x), np.poly1d(np.polyfit(x, y, 1))(np.unique(x))) plt.xticks(x, top_10['country']) plt.title('Linear Regression of Funding vs Country') plt.xlabel('Country')

plt.ylabel('Funding') plt.show()

Current Type: Bar
Current X-axis: funding
Current Y-axis: country
Current Color: None
# This chart shows the top 10 countries by total funding received by their unicorn companies. 
# The United States is the clear leader, with over $1.5 trillion in funding, followed by China with over $500 billion. 
# The rest of the countries in the top 10 have significantly less funding, with the United Kingdom coming in third with just over $100 billion. 
# It's interesting to note that all of the countries in the top 10 are either in North America or Asia, indicating that these regions are the hotspots for unicorn companies and venture capital investment.
  • AI Chat
  • Code