1

I have multiple lists like following

a = [(1,1),(2,2),(3,3),(3, 4)]
b = [("foo", "bar")]
c = [(4938,1203), (329,213)]

I want to convert this to data frame like following

a       b      c
(1,1)  ("foo","bar")  (4938,1203)
(2,2)   NA            (329,213)
(3,3)  NA              NA
(3,4)   NA              NA
1
  • 2
    Like pd.DataFrame([a,b,c], index=list('abc')).T? Commented Nov 10, 2019 at 22:09

1 Answer 1

1

You can just create a dataframe like:

df = pd.DataFrame({'a': pd.Series(a), 'b': pd.Series(b), 'c': pd.Series(c)})

This then will yield:

>>> df = pd.DataFrame({'a': pd.Series(a), 'b': pd.Series(b), 'c': pd.Series(c)})
>>> df
        a           b             c
0  (1, 1)  (foo, bar)  (4938, 1203)
1  (2, 2)         NaN    (329, 213)
2  (3, 3)         NaN           NaN
3  (3, 4)         NaN           NaN
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.