pandas - 在 for 循环中打印变量的名称而不是变量本身
问题描述
我有几个数据框:df_1、df_2、df_3、df_4 等。
我正在尝试遍历它们,执行操作并输出数据框的名称而不是数据框本身。
for k in [df_1, df_2, df_3, df_4]:
k.RandomField.value_counts() #or whatever operations
print(k) #this is where I want it to show "df_1", "df_2", etc instead of printing the variable which, in this case, would be the data frame
我知道我可以创建一个字典,但这需要手动生成一个。感谢你的帮助。
[我正在使用 Jupyter 笔记本并运行 Python 3.8。]
解决方案
推荐阅读
- javascript - 在 heroku 上使用 express 和 mongodb 部署 nuxt.js 的问题
- javascript - ReactJs 事件绑定
- ios - tvOS SearchController,避免折叠键盘
- c++ - 使用模板c ++重载运算符
- rabbitmq - celery 消耗 send_task 响应
- blazor - 如何在 Blazor WebAssembly 应用程序中使用 StackExchange.Redis?
- python - 在 pip install 中使用 libcurl 而不是 urllib3
- angular - Angular Material:mat-select 的问题
- ubuntu - 无法在 U 盘上创建子文件夹,Ubuntu 19.10
- javascript - 如何在codeigniter的单独文本框中用json对象键和值填充输入框