0
以下代碼中的第二個循環似乎忽略「TEST TWO」結果的根列表中的值。我無法弄清楚爲什麼 - 有什麼建議?for循環似乎忽略列表值
import pandas as pd
columns = ['id', 'issye_type']
df = pd.DataFrame(columns=columns)
# print(df)
root = ['issue A',
'issue B'
]
print('\nTEST ONE')
for root in root:
b = df.issye_type.str.startswith(root, na=False).sum()
print('# of', root, "issues: ", b)
print('\nTEST TWO')
for root in root:
c = df.issye_type.str.startswith(root, na=False).sum()
print('# of', root, "issues: ", c)
結果:
TEST ONE
# of issue A issues: 0
# of issue B issues: 0
TEST TWO
# of i issues: 0
# of s issues: 0
# of s issues: 0
# of u issues: 0
# of e issues: 0
# of issues: 0
# of B issues: 0
我有一種感覺,這是用戶錯誤!非常感謝你 - 這讓我瘋狂 – FunnyChef