我想在函数中使用循环逐个传递值python.值存储在数据帧中。你知道吗
def eam(A,B):
y=A +" " +B
return y
假设我将A
的值作为country传递,B
的值作为capital传递。
数据帧df
是
country capital
India New Delhi
Indonesia Jakarta
Islamic Republic of Iran Tehran
Iraq Baghdad
Ireland Dublin
如何使用循环获取值
0 India New Delhi
1 Indonesia Jakarta
2 Islamic Republic of Iran Tehran
3 Iraq Baghdad
4 Ireland Dublin
现在,只需使用以下语法在数据帧中获得一个新列。不需要编写代码来循环行。但是,如果必须循环,数据框箭头()返回或数据框itertuples()提供良好的功能来实现类似的目标。你知道吗
相关问题 更多 >
编程相关推荐