回答編集履歴
2
ソース修正
test
CHANGED
@@ -68,8 +68,6 @@
|
|
68
68
|
|
69
69
|
output_df = pd.merge(master_df, df, left_on='name', right_on='name_key', how='inner').drop("name_key", axis=1)
|
70
70
|
|
71
|
-
|
72
|
-
|
73
71
|
print(output_df)
|
74
72
|
|
75
73
|
'''
|
1
ソース修正
test
CHANGED
@@ -38,11 +38,11 @@
|
|
38
38
|
|
39
39
|
#master_dfのname列を繰り返し処理
|
40
40
|
|
41
|
-
for column_name, item in master_df
|
41
|
+
for column_name, item in master_df.name.iteritems():
|
42
42
|
|
43
43
|
#dfのnameにmaster_dfのnameが含まれる場合、master_dfのnameをdfのname_key列として追加
|
44
44
|
|
45
|
-
df.loc[df
|
45
|
+
df.loc[df.name.str.contains(item), 'name_key'] = item
|
46
46
|
|
47
47
|
print(df)
|
48
48
|
|