0Pricing
Pandas & NumPy Academy · 강의

퍼널 분석

다단계 퍼널의 각 단계에 도달한 사용자 수를 추적하고 연속된 단계 사이의 전환율을 계산합니다.

퍼널 분석은(는) CoddyKit의 무료 Pandas & NumPy Academy 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Pandas & NumPy Academy 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Pandas & NumPy Academy 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

What Is a Conversion Funnel?

A conversion funnel models a user journey through a sequence of required steps: for example, Homepage → Product Page → Add to Cart → Checkout → Purchase. At each step, some users drop off and never reach the next step. Funnel analysis quantifies these drop-offs so teams can prioritise which step to improve first. The output is a table showing user count and conversion rate at each step.

import pandas as pd

FUNNEL_STEPS = [
    'homepage',
    'product_page',
    'add_to_cart',
    'checkout',
    'purchase'
]

df = pd.read_csv('clickstream.csv', parse_dates=['timestamp'])
print(df['event_type'].value_counts())

Counting Unique Users at Each Step

For each funnel step, count the number of unique users who triggered that event at least once. Use df[df['event_type'] == step]['user_id'].nunique() inside a loop and collect the results into a dictionary. Converting to a Series makes subsequent percentage calculations straightforward with a single division.

step_counts = {}
for step in FUNNEL_STEPS:
    users = df[df['event_type'] == step]['user_id'].nunique()
    step_counts[step] = users

funnel = pd.Series(step_counts, name='users')
print(funnel)

Computing Step-to-Step Conversion Rates

The step-to-step conversion rate shows what fraction of users who completed step N also completed step N+1. Compute it with funnel.shift(1) (which gives the previous step's count) and divide: funnel / funnel.shift(1) * 100. The first step has no prior step, so its rate is NaN or 100 % depending on how you define the baseline.

funnel_df = funnel.to_frame()
funnel_df['prev_users'] = funnel_df['users'].shift(1)
funnel_df['step_conversion_%'] = (funnel_df['users'] / funnel_df['prev_users'] * 100).round(1)
print(funnel_df)

Computing Overall Conversion Rate

The overall conversion rate measures what fraction of all users who entered the funnel at step 1 eventually completed the final step. Divide the last step's user count by the first step's count. A 2–5 % overall conversion from homepage to purchase is typical for e-commerce; numbers below this signal a critical drop-off somewhere in the funnel.

overall_rate = funnel.iloc[-1] / funnel.iloc[0] * 100
print(f'Overall conversion rate: {overall_rate:.1f}%')

funnel_df['overall_conversion_%'] = (funnel_df['users'] / funnel_df['users'].iloc[0] * 100).round(1)
print(funnel_df[['users', 'overall_conversion_%']])

Ordered Funnel: Requiring Step Sequence

A simple unique-user count treats users who jumped directly to checkout without visiting the product page as valid funnel entries, which inflates conversion at early steps. To enforce ordering, check that each user reached step N only after reaching step N-1. This requires comparing timestamps: the user must have a product_page event before their add_to_cart event.

# Get first occurrence of each step per user
first_events = df.groupby(['user_id', 'event_type'])['timestamp'].min().unstack('event_type')

# Enforce ordering: each step must come after the previous
first_events['valid_to_cart'] = first_events['add_to_cart'] > first_events['product_page']
print(first_events[['product_page', 'add_to_cart', 'valid_to_cart']].head())

Funnel by Segment: Device Type

Different user segments may convert at very different rates. Run the same funnel calculation separately for desktop and mobile users using groupby('device_type'). If mobile users drop off heavily at the checkout step, the checkout page likely has a usability issue on small screens. Segmented funnels reveal targeted optimisation opportunities.

def funnel_for_group(group_df):
    counts = {}
    for step in FUNNEL_STEPS:
        counts[step] = group_df[group_df['event_type'] == step]['user_id'].nunique()
    return pd.Series(counts)

segmented_funnel = df.groupby('device_type').apply(funnel_for_group)
print(segmented_funnel)

Identifying the Biggest Drop-Off Step

The step with the largest absolute user loss is the highest-priority optimisation target. Find it by computing the difference between consecutive step user counts with funnel.diff() — the most negative value corresponds to the biggest drop-off. Surface this insight in both numeric and visual form for stakeholders.

dropoffs = funnel.diff().abs()
biggest_drop = dropoffs.idxmax()
biggest_drop_count = dropoffs.max()

print(f'Biggest drop-off: {biggest_drop} ({biggest_drop_count:.0f} users lost)')

Time Between Funnel Steps

The time users take to move from one step to the next reveals friction. If users wait hours between adding to cart and checking out, an abandoned-cart email could recover them. Compute the median time between each pair of steps using the first_events DataFrame by subtracting adjacent timestamp columns and taking the median across all users.

for i in range(1, len(FUNNEL_STEPS)):
    prev = FUNNEL_STEPS[i-1]
    curr = FUNNEL_STEPS[i]
    delta = (first_events[curr] - first_events[prev]).dt.total_seconds() / 60
    print(f'{prev} -> {curr}: median {delta.median():.1f} min, 90th pct {delta.quantile(0.9):.1f} min')

Weekly Funnel Trend

Track whether conversion rates are improving or degrading week over week by computing the funnel for each week separately. Group the first-event table by week using first_events['homepage'].dt.isocalendar().week and compute the overall conversion rate per week. A sudden drop in a specific week may coincide with a product release or marketing change.

df['week'] = df['timestamp'].dt.isocalendar().week

weekly_conv = []
for week, wdf in df.groupby('week'):
    top = wdf[wdf['event_type'] == FUNNEL_STEPS[0]]['user_id'].nunique()
    bot = wdf[wdf['event_type'] == FUNNEL_STEPS[-1]]['user_id'].nunique()
    weekly_conv.append({'week': week, 'conversion_%': bot/top*100 if top else 0})

print(pd.DataFrame(weekly_conv))

Building the Funnel Summary DataFrame

Package all funnel metrics into a clean summary DataFrame that can be exported to a report or fed into a visualisation. Include columns for step name, user count, step-to-step conversion, overall conversion, and users lost. This single DataFrame should be the deliverable from funnel analysis, readable by both engineers and product managers.

summary = pd.DataFrame({
    'step': FUNNEL_STEPS,
    'users': [step_counts[s] for s in FUNNEL_STEPS]
})
summary['users_lost'] = summary['users'].shift(-1).rsub(summary['users'])
summary['step_conv_%'] = (summary['users'] / summary['users'].shift(1) * 100).round(1)
summary['overall_conv_%'] = (summary['users'] / summary['users'].iloc[0] * 100).round(1)
print(summary)

Visualising the Funnel as a Bar Chart

Plot the funnel as a horizontal bar chart where each bar's length represents the user count at that step. A funnel shape emerges naturally when bars are sorted from top (most users) to bottom (fewest). Annotate each bar with the step-to-step conversion percentage so the chart is self-contained and does not require a separate data table to interpret.

import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=(8, 5))
ax.barh(summary['step'][::-1], summary['users'][::-1], color='steelblue')
for i, row in summary[::-1].iterrows():
    ax.text(row['users'], i - summary.index[0], f'  {row['step_conv_%']}%', va='center')
ax.set_xlabel('Unique Users')
ax.set_title('Conversion Funnel')
plt.tight_layout()
plt.show()

Quick Check

Test your understanding of Data Analysis concepts from this lesson.

Lesson Recap

In this lesson you learned: counting unique users at each funnel step, computing step-to-step and overall conversion rates, and segmenting funnels by device type and tracking weekly conversion trends. Next up we explore cohort retention tables to track how many users return week after week.

자주 묻는 질문

“퍼널 분석” 강의는 무료인가요?

네 — “퍼널 분석” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Pandas & NumPy Academy 강의 전체를 잠금 해제할 수 있습니다. Pandas & NumPy Academy 강의에는 총 4개의 강의가 포함되어 있습니다.

“퍼널 분석”에서 뭘 배우나요?

다단계 퍼널의 각 단계에 도달한 사용자 수를 추적하고 연속된 단계 사이의 전환율을 계산합니다. 브라우저에서 직접 실행하는 실습 코드로 Pandas & NumPy Academy을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Pandas & NumPy Academy을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Pandas & NumPy Academy은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.

“퍼널 분석” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Pandas & NumPy Academy 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Pandas & NumPy Academy 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 세션화와 이벤트 순서 지정
  2. 퍼널 분석
  3. 코호트 유지율 표
  4. 사용자 여정 시각화
← Pandas & NumPy Academy(으)로 돌아가기