python - 如何在同一标签下绘制整个 Pandas DataFrame?
问题描述
我正在尝试编写一个带有 2 个参数的绘图函数 - 一个 DataFrame 和一个 label (df1 and label1)
。如果我有更多数据组要绘制,我的函数还有可选参数来添加更多 DataFrame:
def REE_GroupPlot(df1, label1,
df2=None, label2=None,
df3=None, label3=None,
df4=None, label4=None,
df5=None, label5=None):
我正在尝试将单个 DataFrame 中的所有列绘制在相同的键标签和相同的颜色下,但我不太确定如何。我已经调查过了pd.groupby
,但我似乎无法让它做我想做的事。
我将不胜感激任何建议 - 谢谢!
解决方案
如果你传入一个数据框列表,比如
def REE_Group_Plot(dfs, label):
# combine all dataframes into 1
all_dfs = pd.concat(dfs)
# the rest of the code to plot the graph
REE_Group_Plot(dfs=[df, df2, df3, df4], label = “ABC”)
推荐阅读
- python - 如何在python中计算在线pdf的页数?
- android - 如何从 android / kotlin 中的 firebase 读取子数据的子数据
- vue.js - vuejs treeselect - 延迟加载不能通过 vuex 操作工作
- php - 如何格式化 JSON 对象 PHP
- amazon-web-services - 如何在 spark-submit 命令中增加 AM 容器大小?错误:容器运行超出物理内存限制
- java - Spring Boot 无法识别带有发送请求参数的控制器
- javascript - 使用选定的选项填充 html 表
- c - C - 检查字符串的最后一个字符是否等于“#”
- unix - Bourne - 预期二元运算符
- firebase-security - 如何允许 firebase 用户仅访问他们创建的文档