Python: извлечение подстроки из String с использованием Dataframe - PullRequest
0 голосов
/ 06 марта 2019

Попытка извлечь подстроку из строки.Работает для одной записи, но получает NAN для нескольких записей.

Ожидаемый результат:

1st Row:HKA-33711-15293045
2nd row:HKA-94612-14661285

Код проверки:

df1['o_position'] = df1['Event Value'].str.find('HKA-')
df1['o_position_to_18'] = df1['o_position']+18
df1["order_id"]=df1["Event Value"].str.slice(start=df1["o_position"],stop=df1['o_position_to_18'])
df1.head()

Данные:

{'"af_currency"':'"INR"','"af_revenue"':429,'"af_customer_user_id"':'"33738413"','"af_price"':['"399"'],'"af_receipt_id"':'"HKA-33711-15293045"','"af_content_id"':['"72769"'],'"sessionId"':'"-1551484318545"','"af_quantity"':['"1"'],'"af_param_1"':'"HKA-33711-15293045"','"af_content_type"':'"order"'}

2-я строка:

{'"af_price"':['"2199"'],'"af_content_id"':['"72289"'],'"af_quantity"':['"1"'],'"af_param_1"':'"HKA-94612-14661285"','"af_content_type"':'"order"','"af_currency"':'"INR"','"af_revenue"':2199,'"af_receipt_id"':'"HKA-94612-14661285"'}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...