python - 遍历数据框名称
问题描述
我想在 for 循环中打印 Dataframe 的名称,但是我不正确当我遍历数据集列表时,我得到了数据集。例如,如果我尝试使用 str(d),我会将所有数据集作为字符串。d.name() 也不起作用。
我该怎么做才能将 Dataframe 的名称打印为字符串?
提前致谢!
PD:我收到此错误,“AttributeError:'DataFrame' 对象没有属性'名称'”
# Define lists
datasets = [train_data, test_data]
features = ['Age', 'Fare']
# Create function
fig, outliers = plt.subplots(figsize=(20,10), ncols=4)
row, col = 0, 0
for f in features:
for d in datasets:
sns.boxplot(x=d[f], orient='v', color=pal_titanic[3], ax=outliers[col])
outliers[col].set_title(f + 'in' + d)
col = col + 1
解决方案
推荐阅读
- mysql - 如何从部分不同值的每个子集中仅选择第一行?
- c - 为什么我的函数会产生冲突类型错误?
- c# - 按数据网格、组合框、日期时间选择器搜索
- flutter - 如何在 dart/flutter 中迭代 2 个不同数组中的每个值?
- raspberry-pi - 我可以将 raspi-lora 与 The Things Network 一起用于 Raspberry 端节点吗
- c# - SQL插入函数在没有连接时崩溃
- vba - VBA:“CreateObject(“System.Security.Cryptography.HMACSHA1”)的自动化错误
- c++ - 应该在 C++ 源代码中修改什么以生成显示函数和运算符名称的控制流图?
- python - TypeError:使用 trapz 方法时,只能将 size-1 数组转换为 Python 标量
- javascript - 我的粘性滚动导航在 js 文件中不起作用