Skip to content
Experiment with the AI assistant
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.
DataFrameas
df
variable
SELECT company, country
FROM companies;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.
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.graph_objects as go
# Assuming you have the necessary data for the top 10 countries and their funding
countries = ['Country A', 'Country B', 'Country C', 'Country D', 'Country E', 'Country F', 'Country G', 'Country H', 'Country I', 'Country J']
funding = [100, 200, 150, 300, 250, 180, 220, 190, 280, 230]
# Create a bar chart using plotly
fig = go.Figure(data=go.Bar(x=countries, y=funding))
# Set the chart title and axis labels
fig.update_layout(title='Top 10 Countries by Total Funding', xaxis_title='Country', yaxis_title='Funding')
# Display the chart
fig.show()May the AI force be with you! 🤖
import plotly.express as px
import pandas as pd
# Load data
df = pd.read_csv('funding_data.csv')
# Group by country and sum the funding
df = df.groupby('country')['funding'].sum().reset_index()
# Sort by funding in descending order and select top 10 countries
df = df.sort_values('funding', ascending=False).head(10)
# Plot bar chart
fig = px.bar(df, x='country', y='funding', title='Top 10 Countries by Total Funding')
fig.show()