我有pandas.DataFrame
df.columns = ['jobID', 'emailAddress', 'jobTitle', 'jobSource', 'contactName']
和index_col = 'jobID'
我的目标是循环遍历此数据框的每一行,并根据每个“单元格”(列和行的交集)的值创建变量,并将其传递给我编写的自动生成和发送电子邮件的函数。
这是我到目前为止所做的,但这并没有完成它。
for row in df.index():
email = str(df['emailAddress'])
jobTitle = str(df['jobTitle'])
jobSource = str(df['jobSource'])
jobID = str(df['jobID'])
nameOfContact = str(df['contactName'])
""" generate the email subject using string methods
'This is a subject about %s' % (jobTitle)
"""
subj = emailSubj(jobSource = jobSource,
jobTitle = jobTitle,
jobID = jobID)
"""
create email body using similar logic as subject
"""
body = create_emailBody(nameOfContact = nameOfContact)
"""
Generate and send the email by passing email address, subject, body
"""
emailTool(email = email,
subj = subj,
body = body)
这个脚本确实运行了,但我认为我没有正确地循环遍历行并命名变量。我收到的是整个列而不是单元格。
答案 0 :(得分:1)
您可以使用php.ini
:
.apply(..., axis=1)