Dataframe拆分查询

时间:2018-06-04 07:32:11

标签: dataframe split

我有一个数据框列,其中包含每行中的所有文字

Symbol(id=15351, ticker=VXX, market=US, currency=USD, type=EQUITY,tick_size=0.010000, lot_size=100, contract_size=0, rate=None)

我试图仅在ticker =之后提取,这给出了VXX

我试过

df['symbolcolumn']  = df['symbolcolumn'].str.split(',market', expand=True)

但它不会仅提取符号代码

寻找df['symbolcolumn'] = VXX

你能告诉我吗?

1 个答案:

答案 0 :(得分:0)

好的,我设法通过

来做到了
df['symbol'] = df['symbol'].astype(str)
df['symbol'] = df['symbol'].str.split(', market', expand=True)
df['symbol'] = df['symbol'].apply(lambda x: x.split("=")[-1])