Visualise the data in the untitled.csv file using a line chart. add a trendline for each segment (all workspaces, business workspaces)
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# Load the data from the CSV file
file_path = 'Untitled spreadsheet - Funnel conversion over time - Workspace created to integration created (last 6 months).csv'
data = pd.read_csv(file_path)
data.head()
Run to view results
# Transform the data to a long format for easier plotting
import pandas as pd
data_long = data.melt(id_vars=['\tSegment', '\tSteps'], var_name='Date', value_name='Conversion Rate')
data_long['Date'] = pd.to_datetime(data_long['Date'])
data_long.head()
Run to view results
# Plot the data with trendlines for each segment
plt.figure(figsize=(14, 7))
sns.set_theme(style="whitegrid")
# Plot line chart
sns.lineplot(data=data_long, x='Date', y='Conversion Rate', hue='\tSegment', marker='o')
# Add trendlines
sns.regplot(data=data_long[data_long['\tSegment'] == '\tAll workspaces'], x='Date', y='Conversion Rate', scatter=False, color='b', label='All workspaces Trend')
sns.regplot(data=data_long[data_long['\tSegment'] == '\tBusiness Workspaces'], x='Date', y='Conversion Rate', scatter=False, color='orange', label='Business Workspaces Trend')
plt.title('Conversion Rate Over Time with Trendlines')
plt.xlabel('Date')
plt.ylabel('Conversion Rate')
plt.legend()
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
Run to view results