Skip to content

Commit

Permalink
style: ✨ output improvements (#78)
Browse files Browse the repository at this point in the history
Co-authored-by: Omer Kayabasi <[email protected]>
  • Loading branch information
amedumer and Omer Kayabasi authored Dec 19, 2024
1 parent c0be7c6 commit 8426e0f
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions src/exploratory.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,28 +167,30 @@ def summary(self):
].drop_duplicates()
print(
f"""
table: data_customers
date start: {data_customers[self.registration_time_col].min()}
date end: {data_customers[self.registration_time_col].max()}
period: {(data_customers[self.registration_time_col].max()-data_customers[self.registration_time_col].min()).days/365:.2f} years
customers: {data_customers[self.uuid_col].nunique():,d}
events: {data_customers.shape[0]:,d}
"""
)
**Customer Data Table**
- Date start: {data_customers[self.registration_time_col].min()}
- Date end: {data_customers[self.registration_time_col].max()}
- Period: {(data_customers[self.registration_time_col].max()-data_customers[self.registration_time_col].min()).days/365:.2f} years
- Total Customers: {data_customers[self.uuid_col].nunique():,d} customers.
- Total Events: {data_customers.shape[0]:,d} events.
"""
)
data_events = self.joined_df[~self.joined_df[self.event_time_col].isnull()]
unique_event_types = data_events[self.event_name_col].nunique()
event_list = list(data_events[self.event_name_col].unique())

data_events = self.joined_df[~self.joined_df[self.event_time_col].isnull(
)]
print(
f"""
table: self.data_event
date start: {data_events[self.event_time_col].min()}
date end: {data_events[self.event_time_col].max()}
period: {(data_events[self.event_time_col].max()-data_events[self.event_time_col].min()).days/365:.2f} years
customers: {data_events[self.uuid_col].nunique():,d}
events: {data_events.shape[0]:,d}
unique events: {data_events[self.event_name_col].nunique():,d}
events / customer: {(data_events.shape[0] / data_events[self.uuid_col].nunique()):.2f}
"""
**Event Data Table**
- Date start: {data_events[self.event_time_col].min()}
- Date end: {data_events[self.event_time_col].max()}
- Period: {(data_events[self.event_time_col].max()-data_events[self.event_time_col].min()).days/365:.2f} years
- Total Customers: {data_events[self.uuid_col].nunique():,d} customers.
- Total Events: {data_events.shape[0]:,d} events.
- Unique Event Types: {unique_event_types}.
- Event list: {event_list}
- Average Events per Customer: {(data_events.shape[0] / data_events[self.uuid_col].nunique()):.2f} events/customer.
"""
)

# All plot methods
Expand Down Expand Up @@ -482,8 +484,8 @@ def plot_customers_histogram_per_conversion_day(
data,
x_axis="dsi",
y_axis=self.uuid_col,
xlabel="",
ylabel="",
xlabel="Days Since Registration",
ylabel="% Purchased Customers",
y_format="%",
title=title,
)
Expand Down Expand Up @@ -606,6 +608,8 @@ def plot_early_late_revenue_correlation(
fig = self.graph.heatmap_plot(
customer_revenue_data,
title="Correlation matrix of revenue per user by different days since registration\n",
xlabel="Days Since Registration",
ylabel="Days Since Registration",
)

# Highlight the day when correlation drops below 50%
Expand Down

0 comments on commit 8426e0f

Please sign in to comment.