【发布时间】:2021-12-21 00:17:04
【问题描述】:
import pandas as pd
data = {'Product Description': [': da tổng hợp, khung gỗ sồi canada.', ': gỗ mfc phủ melamine, chân thép sơn tĩnh']}
df = pd.DataFrame(data)
def add_material(row):
lst = []
temp = row['Product Description']
for i in temp:
if 'da tổng hợp' in temp:
lst.append('Synthetic Leather')
elif 'gỗ sồi' in temp:
lst.append('Oak')
elif 'gỗ mfc phủ melamine' in temp:
lst.append('Melamine coated MFC Wood')
elif 'chân thép' in temp:
lst.append('Steel')
return lst
continue
df['Material'] = df.apply(add_material, axis = 1)
“材料”列中的列表不包含第二种材料。我想要这样的第二列:
cols_2 = {'Material': [['Synthetic Leather', 'Oak'], ['Melamine coated MFC Wood', 'Steel']]}
谢谢。
【问题讨论】: