I'm doing some study on the below df
timestamp conversationId UserId MessageId tpMessage Message
1614578324 ceb9004ae9d3 1c376ef 5bbd34859329 question Where do you live?
1614578881 ceb9004ae9d3 1c376ef d3b5d3884152 answer Brooklyn
1614583764 ceb9004ae9d3 1c376ef 0e4501fcd61f question What's your name?
1614590885 ceb9004ae9d3 1c376ef 97d841b79ff7 answer Phill
1614594952 ceb9004ae9d3 1c376ef 11ed3fd24767 question What's your gender?
1614602036 ceb9004ae9d3 1c376ef 601538860004 answer Male
1614602581 ceb9004ae9d3 1c376ef 8bc8d9089609 question How old are you?
1614606219 ceb9004ae9d3 1c376ef a2bd45e64b7c answer 35
1614606240 loi90zj8q0qv 1c890r9 o2bd10ex4b8u question Where do you live?
1614606240 jto9034pe0i5 1c489rl o6bd35e64b5j question What's your name?
1614606250 jto9034pe0i5 1c489rl 96jd89i55b72 answer Robert
1614606267 jto9034pe0i5 1c489rl 33yd1445d6ut answer Brandom
1614606267 loi90zj8q0qv 1c890r9 o2bd10ex4b8u answer London
1614606287 jto9034pe0i5 1c489rl b7q489iae77t answer Connor
I need to "split" the timestamp column in 2 based on the tpMessage column, the contidions are:
df['ts_question'] = np.where(df['tpMessage']=='question', df['timestamp'],0)
df['ts_answer'] = np.where(df['tpMessage']=='answer', df['timestamp'],0)
this is giving me "0" values for both columns when the conditions don't match and I'm stuck in how to move forward after that
my goal is to get this output:
ts_question ts_answer conversationId UserId
1614578324 1614578881 ceb9004ae9d3 1c376ef
1614583764 1614590885 ceb9004ae9d3 1c376ef
1614594952 1614602036 ceb9004ae9d3 1c376ef
1614602581 1614606219 ceb9004ae9d3 1c376ef
1614606240 1614606250 jto9034pe0i5 1c489rl
1614606240 1614606267 o2bd10ex4b8u 1c890r9
1614606240 1614606267 o2bd10ex4b8u 1c489rl
1614606240 1614606287 jto9034pe0i5 1c489rl
note that I can have 1 or more answers for the question "What's your name"?
Edit : I found out that I can have N conversations happening at the same timestamp(i.e. 1614606240 and 1614606267)
could you guys help me on that