как мне отредактировать следующий скрипт, чтобы сохранить выходные данные как новые переменные в исходном кадре данных?
AKA: вместо функции печати выходные данные сохраняются в виде новой переменной для каждого оператора if elif?
import re
df = pd.read_excel('edmundstest.xlsx')
for Keyword, Landing_Page in zip(df["Keyword"], df["Landing_Page"]):
# the url
if "/2019/" in Landing_Page:
new_model_core_incentives = Landing_Page
print(f"new_model_core_incentives {new_model_core_incentives}")
elif re.search("/(?:(?:20)|(?:19))\d{2}/", Landing_Page):
used_model_core_incentives = Landing_Page
print(f"used_model_core_incentives {used_model_core_incentives}")
# the "keywords"
if "2019" in Keyword:
new_word = Keyword
print(f"new_word {new_word}")
elif re.search("/(?:(?:20)|(?:19))\d{2}/", Keyword) is None:
old_word = Keyword
print(f"old_word {old_word}")
т.е.: new_model_core_incentives
или used_model_core_incentives
в качестве новой переменной в кадре данных и new_word
и old_word
в качестве новой переменной в кадре данных?