我正在编写一个函数,其参数为pandas
系列,并且我希望能够打印pandas
系列的名称。这是我到目前为止拥有的功能:
def chi2_ind_reps(x):
if chi2_ind(df['n_killed'], x) is True:
print('n_killed is dependent on ')
if chi2_ind(df['n_injured'], x) is True:
print('n_injured is dependent on ')
例如,我希望chi2_ind_reps(df['date'])
返回
n_killed is dependent on df['date']
n_injured is dependent on df['date']
我尝试使用str()
函数,但这只会将整个系列作为字符串对象返回。
有什么建议吗?