【发布时间】:2021-06-21 05:14:30
【问题描述】:
我想在excel 数据帧中创建一个新列"HQ_LOC",它将来自wharton['conm'] 的字符串j 作为值
xls = excel[(excel['prowess_compustat_h1b'] == 1) | (excel['compustat_h1b'] == 1)]
excel['HQ_LOC'] = pd.Series([])
for name in xls["coname"]:
for j in wharton['conm']:
if name == j:
j
excel['HQ_LOC'].append(j)
但是当我运行上面的代码时,会出现以下错误,即使我将excel['HQ_LOC'] 转换为 Pandas 系列
TypeError: cannot concatenate object of type '<class 'str'>'; only Series and DataFrame objs are valid
【问题讨论】:
标签: python pandas dataframe typeerror