0

I have a DataFrame df with several columns, including expiry and iv. I would like to create a lol = list-of-list [[]] so that each row in the lol corresponds to a given expiry. For example, say df look like this:

df =


expiry             iv
===========================
2019-01-18,        .18
2019-01-18,        .17
2019-01-18,        .16
2019-02-18,        .14
2019-02-18,        .13
2019-02-18,        .12

the lol would look like this:

lol = [
[0.18, 0.17, 0.16],
[0.14, 0.13, 0.12]]

So each row of the lol would correspond to the corresponding date in the df.

1 Answer 1

2

IIUC

LoL=df.groupby('expiry').iv.agg(list).tolist()
LoL
[[0.18, 0.17, 0.16], [0.14, 0.13, 0.12]]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.