我正在编写一个绘制数据框图的函数,我想根据传递给该函数的数据框的名称来命名这些图。绘图仪功能的第一行是:
def plotter(data):
假设要传递的数据帧是df1
,我想知道'df1'
调用时如何获取字符串plotter(data=df1)
?
你可以这样做:
from varname import nameof
def plotter(data, name_df):
# name_df is a string which is is "df1", then you can add to the plot
plotter(df1, nameof(df1))
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句