Skip to content

Speed Up Your Process Using the Workspace AI Assistant

Discover the power of our AI Assistant. Get started with exciting prompts that will supercharge your data workflow!

The sample dataset we'll use here consists of orders made with a UK-based online retailer from December 2010 to December 2011. Source of dataset.

1. Fix errors

The cell below contains an error. You can press "Fix & Explain" to get your AI Assistant to fix it for you and explain what was wrong with the code.

this_is_a_variable = 42
print(this_is_a_variable)

SELECT department, AVG(salary) AS average_salary FROM employees GROUP BY department ORDER BY average_salary DESC;

import folium

Coordinates for London

london_coords = [51.5074, -0.1278]

Create a map centered on London

m = folium.Map(location=london_coords, zoom_start=10)

Add a marker for London

folium.Marker( location=london_coords, popup="London", icon=folium.Icon(color="blue", icon="info-sign") ).add_to(m)

Display the map

m

import folium

# Create a map centered around New York
map = folium.Map(location=[40.7128, -74.0060], zoom_start=12)

# Add a marker for New York
folium.Marker(location=[40.7128, -74.0060], popup='New York').add_to(map)

# Display the map
map

Import essential packages for a machine learning classification task

Data manipulation and analysis

import numpy as np import pandas as pd

Data visualization

import matplotlib.pyplot as plt import seaborn as sns

Machine learning models and utilities

from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler, LabelEncoder from sklearn.metrics import classification_report, confusion_matrix, accuracy_score from sklearn.ensemble import RandomForestClassifier from sklearn.linear_model import LogisticRegression from sklearn.svm import SVC

Optional: Suppress warnings for cleaner output

import warnings warnings.filterwarnings('ignore')

import pandas as pd import plotly.express as px

Load the dataset

df = pd.read_csv('online_retail.csv', encoding='ISO-8859-1')

Convert InvoiceDate to datetime

df['InvoiceDate'] = pd.to_datetime(df['InvoiceDate'])

Filter for 2011 data only

df_2011 = df[df['InvoiceDate'].dt.year == 2011]

Remove rows with missing or negative values

df_2011 = df_2011.dropna(subset=['Quantity', 'UnitPrice']) df_2011 = df_2011[(df_2011['Quantity'] > 0) & (df_2011['UnitPrice'] > 0)]

Calculate sales per row

df_2011['Sales'] = df_2011['Quantity'] * df_2011['UnitPrice']

Extract month

df_2011['Month'] = df_2011['InvoiceDate'].dt.month

Group by month and sum sales

monthly_sales = df_2011.groupby('Month')['Sales'].sum().reset_index()

Map month numbers to names (optional)

import calendar monthly_sales['Month'] = monthly_sales['Month'].apply(lambda x: calendar.month_name[x])

Create Plotly bar plot

fig = px.bar(monthly_sales, x='Month', y='Sales', title='Monthly Sales in 2011', labels={'Sales': 'Total Sales', 'Month': 'Month'}, text_auto='.2s')

fig.update_layout(xaxis_title='Month', yaxis_title='Total Sales (£)', xaxis={'categoryorder':'array', 'categoryarray':list(calendar.month_name)[1:]})

fig.show()

What else will you do with it?

It's up to you now! How will you use your new AI Assistant?

Looking for more prompts to try? The following tutorial has more: 10 Ways to Speed Up Your Analysis With the Workspace AI Assistant

Looking for more datasets to explore? We have a bunch of datasets your new AI Assistant will love to explore!