获取数据框的名称[Python] [英] Get the name of the dataframe [Python]

查看:1625
本文介绍了获取数据框的名称[Python]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取DataFrame的名称并将其作为字符串打印?谢谢大师!

How do I get the name of the DataFrame and print it as a string? Thank you masters!

示例:

boston(将名称分配给csv文件)

boston (var name assigned to a csv file)

boston = read_csv('boston.csv')

print ('The winner is team A based on the %s table.) % boston


推荐答案

您可以命名数据框然后调用这个名字,不管你喜欢什么:

You can name the dataframe with the following, and then call the name wherever you like:

import pandas as pd
df = pd.DataFrame( data=np.ones([4,4]) )
df.name = 'Ones'

print df.name
>>>
Ones

希望有所帮助。

这篇关于获取数据框的名称[Python]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆