9.3 数据分析助手
9.3.1 核心模式:Code Interpreter
实战:CSV 深度分析
import pandas as pd df = pd.read_csv('user_behavior_2025.csv') print(df.head()) print(df.info())# 转换日期格式 df['signup_date'] = pd.to_datetime(df['signup_date']) df['last_active'] = pd.to_datetime(df['last_active']) # 计算用户所属的 cohort month df['cohort_month'] = df['signup_date'].dt.to_period('M') # ... 省略中间的 pivot table 计算逻辑 ... # 得到 retention_matrix print(retention_matrix)import plotly.express as px fig = px.imshow(retention_matrix, text_auto='.1%', title="User Retention Cohort Analysis") fig.write_html("cohort_heatmap.html")
9.3.2 Text-to-SQL:让非技术人员查库
架构设计与 Self-Correction
9.3.3 自动可视化
9.3.4 真实案例:某电商运营助手
最后更新于
