初级
现金流分析:三类现金流增长率趋势对比
未完成
初级参考
完整示例代码供参考,建议自己理解后重新输入
"""
金融风险管理 - q041
现金流异常分析:三类现金流增长率趋势对比
"""
metadata = {
"id": "q041",
"title": "现金流分析:三类现金流增长率趋势对比",
"module": "现金流异常分析",
"difficulty": "beginner",
"data_files": ["case34_yutong_operating.csv"],
"skills": ["增长率计算", "趋势对比", "现金流结构"],
"estimated_minutes": 8
}
"""
【题目】
读取case34_yutong_operating.csv,分析宇通客车营收、利润、现金流三者增长率的趋势。
数据已包含 revenue_growth、profit_growth、ocf_growth 字段。
输出DataFrame,index为year,包含:revenue_growth、profit_growth、ocf_growth
并追加一列"现金流背离":若ocf_growth与profit_growth差异绝对值>0.5,标记"⚠ 背离",否则"一致"
所有增长率保留4位小数。
"""
def solve():
import pandas as pd
from pyodide.http import open_url
from io import StringIO
BASE_URL = "https://data.zuihe.com/finance/"
df = pd.read_csv(StringIO(open_url(BASE_URL + "case34_yutong_operating.csv").read()))
df = df.set_index('year')
df['现金流背离'] = df.apply(
lambda r: '⚠ 背离' if abs(r['ocf_growth'] - r['profit_growth']) > 0.5 else '一致', axis=1)
result = df[['revenue_growth', 'profit_growth', 'ocf_growth', '现金流背离']]
return result.to_string()
if __name__ == "__main__":
print(solve())
示例
输入
solve()
期望输出
revenue_growth profit_growth ocf_growth 现金流背离 | year | 2007 45.83 97.80 -25.22 ⚠ 背离 | 2008 3.51 16.70 40.73 ⚠ 背离 | 2009 5.35 8.21 -92.43 ⚠ 背离
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199