@@ -1006,7 +1006,7 @@ def calculate_funnel_metrics(
10061006 Returns:
10071007 FunnelResults object with all calculated metrics
10081008 """
1009- start_time = time .time ()
1009+ time .time ()
10101010
10111011 if len (funnel_steps ) < 2 :
10121012 return FunnelResults (
@@ -1088,7 +1088,7 @@ def _calculate_funnel_metrics_polars(
10881088 existing_events_in_data = set (
10891089 polars_df .select ("event_name" ).unique ().to_series ().to_list ()
10901090 )
1091- funnel_steps_in_data = set (funnel_steps ) & existing_events_in_data
1091+ set (funnel_steps ) & existing_events_in_data
10921092
10931093 zero_counts = [0 ] * len (funnel_steps )
10941094 drop_offs = [0 ] * len (funnel_steps )
@@ -1167,7 +1167,6 @@ def _calculate_funnel_metrics_polars(
11671167
11681168 # Ensure consistent data types between DataFrames
11691169 # Get the schema of segment_polars_df
1170- segment_schema = segment_polars_df .schema
11711170
11721171 # Cast user_id in both DataFrames to string to ensure consistent types
11731172 segment_polars_df = segment_polars_df .with_columns (
@@ -1272,7 +1271,7 @@ def _calculate_funnel_metrics_pandas(
12721271 return FunnelResults ([], [], [], [], [])
12731272 # Events exist but none match funnel steps - check if any of the funnel steps exist in the data at all
12741273 existing_events_in_data = set (events_df ["event_name" ].unique ())
1275- funnel_steps_in_data = set (funnel_steps ) & existing_events_in_data
1274+ set (funnel_steps ) & existing_events_in_data
12761275
12771276 zero_counts = [0 ] * len (funnel_steps )
12781277 drop_offs = [0 ] * len (funnel_steps )
@@ -2013,7 +2012,7 @@ def _calculate_timeseries_metrics_pandas(
20132012
20142013 # Define first and last steps
20152014 first_step = funnel_steps [0 ]
2016- last_step = funnel_steps [- 1 ]
2015+ funnel_steps [- 1 ]
20172016 conversion_window_hours = self .config .conversion_window_hours
20182017
20192018 try :
@@ -3250,7 +3249,7 @@ def _calculate_path_analysis_polars_optimized(
32503249 # Fully vectorized approach for between-steps analysis
32513250 try :
32523251 # Get unique user IDs with valid conversion pairs
3253- user_ids = conversion_pairs .select ("user_id" ).unique ()
3252+ conversion_pairs .select ("user_id" ).unique ()
32543253
32553254 # Create a lazy frame with step pairs information
32563255 step_pairs_lazy = conversion_pairs .lazy ().select (
@@ -3785,7 +3784,7 @@ def _analyze_between_steps_polars(
37853784 continue
37863785
37873786 step_A_time = user_A [0 , "step_A_time" ]
3788- conversion_window = timedelta (hours = self .config .conversion_window_hours )
3787+ timedelta (hours = self .config .conversion_window_hours )
37893788
37903789 # Find first B after A within conversion window
37913790 potential_Bs = user_B .filter (
@@ -4576,7 +4575,7 @@ def _calculate_unique_pairs_funnel_polars(
45764575 users_count .append (count )
45774576
45784577 # For unique pairs, conversion rate is step-to-step
4579- step_conversion_rate = (
4578+ (
45804579 (count / len (prev_step_users ) * 100 ) if len (prev_step_users ) > 0 else 0
45814580 )
45824581 # But we also track overall conversion rate from first step for consistency
@@ -5694,7 +5693,7 @@ def _user_did_later_steps_before_current(
56945693 try :
56955694 # Get the funnel sequence from the order that steps appear in the overall dataset
56965695 # This is a heuristic but works for most cases
5697- all_funnel_events = all_events_df ["event_name" ].unique ()
5696+ all_events_df ["event_name" ].unique ()
56985697
56995698 # For the test case, we know the sequence should be: Sign Up -> Email Verification -> First Login
57005699 # When checking Email Verification after Sign Up, we should see if First Login happened before Email Verification
@@ -5888,7 +5887,7 @@ def _calculate_unique_pairs_funnel(
58885887 users_count .append (count )
58895888
58905889 # For unique pairs, conversion rate is step-to-step
5891- step_conversion_rate = (
5890+ (
58925891 (count / len (prev_step_users ) * 100 ) if len (prev_step_users ) > 0 else 0
58935892 )
58945893 # But we also track overall conversion rate from first step
@@ -5929,7 +5928,7 @@ def _user_did_later_steps_before_current_polars(
59295928 try :
59305929 # Find the indices of steps in the funnel
59315930 try :
5932- prev_step_idx = funnel_steps .index (prev_step )
5931+ funnel_steps .index (prev_step )
59335932 current_step_idx = funnel_steps .index (current_step )
59345933 except ValueError :
59355934 # If the steps aren't in the funnel, we can't determine order
0 commit comments