python - Prevent Pandas from unpacking a tuple when creating a dataframe from dict -


when creating dataframe in pandas dictionary, tuple automatically expanded, i.e.

import pandas d = {'a': 1, 'b': 2, 'c': (3,4)} df = pandas.dataframe.from_dict(d) print(df) 

returns

    b  c 0  1  2  3 1  1  2  4 

apart converting tuple string first, there way prevent happening? want result be

    b  c 0  1  2  (3, 4) 

try add [], value in dictionary key c list of tuple:

import pandas  d = {'a': 1, 'b': 2, 'c': [(3,4)]} df = pandas.dataframe.from_dict(d)  print(df)     b       c 0  1  2  (3, 4) 

Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -