def call_panda():
filename = 'C:\\file.csv'
cols_to_use = ['col1', 'col2', 'col3', 'col4']
df = pd.read_csv(filename, nrows= 5,usecols=cols_to_use,index_col='col1')
# Send email
me = 'me@email.com'
you = 'you@email.com'
textfile = df
with open(textfile, 'rb') as fp:
msg = MIMEText(fp.read())
msg['Subject'] = 'Contents of file'
msg['From'] = me
msg['To'] = you
s = smtplib.SMTP('mailhost.acme.net')
s.sendmail(me, [you], msg.as_string())
s.quit()
Error Message is with open(textfile, 'rb') as fp: TypeError: expected str, bytes or os.PathLike object, not DataFrame