# Split place_with_parent_names column by "|"
split_names = df1["place_with_parent_names"].str.split("|")
# Find index of "Brasil" in each list and add 1 to get index of state name
state_index = split_names.apply(lambda x: x.index("Brasil") + 1)
# Extract state name using state_index
df1["state"] = split_names.apply(lambda x: x[state_index.iloc[0]])
1条答案
按热度按时间gzszwxb41#
列创建状态
根据我的理解
我正在写这段代码
请做upvote和支持我猜它的工作