Code:
import pandas as pd app = pd.read_excel("/Users/michaelblack/Downloads/Applicants with Interest/Applicants with Interests 2020.xlsx") app = app.replace(',',' ', regex=True).replace('/','', regex=True).replace('-','',regex=True).replace(';',' ',regex=True) pd.set_option('display.max_columns', None) pd.set_option('display.max_colwidth', None) app.fillna(' ', inplace = True) app.info() ct = 0 while ct <= 9: if ct == 0: app['new'+str(ct)] = app['Interest Description'] + ' ' + app['Interest Role'] else: app['new'+str(ct)] = app['Interest Description' + '.' + str(ct)] + ' '+ app['Interest Role' + '.' + str(ct)] ct += 1 app.head(5)
My error is on line 12 (right above ct += 1) and it is a "can only concatenate str (not "int") to str".
For context: every single field in my Excel file is an "object" data type, and I have two other Excel files with the exact same # of columns, column headers, and data types, but just different values, and they both work.
Can anyone please offer some guidance here? For the life of me, I am lost. I can't understand why one identical Excel file would work but another wouldn't, when the code is the EXACT same.
https://stackoverflow.com/questions/66609357/i-have-no-idea-why-i-am-getting-can-only-concatenate-str-not-int-to-str-er March 13, 2021 at 09:43AM
没有评论:
发表评论