如何找出熊貓數據框的列中存在的每個元素? 我願做這樣的事情:如何遍歷熊貓數據框列中的元素?
for item in column:
print("usercode = " + item)
# OUTPUT:
# usercode = key00
# usercode = key01
# usercode = key02
數據幀是這樣的:
USERCODES NAMES
0 key00 ab00
1 key01 cd01
2 key02 ef02
如何找出熊貓數據框的列中存在的每個元素? 我願做這樣的事情:如何遍歷熊貓數據框列中的元素?
for item in column:
print("usercode = " + item)
# OUTPUT:
# usercode = key00
# usercode = key01
# usercode = key02
數據幀是這樣的:
USERCODES NAMES
0 key00 ab00
1 key01 cd01
2 key02 ef02
以及在列中的每個值使用Series.apply
:
def f(item):
print("usercode = " + item)
df['NAMES'].apply(f)
usercode = ab00
usercode = cd01
usercode = ef02
一號線:
df['NAMES'].apply(lambda item: print("usercode = " + item))
usercode = ab00
usercode = cd01
usercode = ef02
Simpliest:
for item in df['NAMES']:
print("usercode = " + item)
usercode = ab00
usercode = cd01
usercode = ef02
'對於i,排在df.iterrows():打印(行[ 'USERCODES'])' –