How to convert list into workable dataframe or dictionary?


This Content is from Stack Overflow. Question asked by Athens Nwo

I have this data output (as markers) which looks like this:

{'0': ['DUSP4', 'AC017002.3', 'LINC02804', 'GML', 'GNAO1', 'AC025946.1', 'TGFBR3L', 'EDN3', 'TMEM200A', 'MSC-AS1', 'ZP1', 'MSC', 'AC090515.6', 'LINC00892', 'HAS3', 'PLSCR2', 'SLC44A3', 'AC013460.1', 'CNTNAP1', 'TMPRSS11E', 'LINC01229', 'WDR17', 'TNFRSF18', 'LINC02295'], '1': ['ZP1', 'AIRE', 'RORC', 'TTC39C-AS1', 'AC010531.5', 'AC016821.1', 'WDR86-AS1', 'B3GNT9', 'TMPRSS11E', 'CYP4B1', 'CDO1', 'KRT7', 'ZDHHC11B', 'CNTNAP1', 'IL17RB', 'MYRF']}

Which I exported it running this code:

df = pd.DataFrame(list(markers.items()), columns = ['cluster_id','marker'])

which resulted in this:

1‘ZP1’, ‘AIRE’, ‘RORC’, ‘TTC39C-AS1’, ‘AC010531.5’, ‘AC016821.1’, ‘WDR86-AS1’, ‘B3GNT9’, ‘TMPRSS11E’, ‘CYP4B1’, ‘CDO1’, ‘KRT7’, ‘ZDHHC11B’, ‘CNTNAP1’, ‘IL17RB’]

How do I “convert” this dataset into workable dataframe so that I subset markers that are in cluster_id zero?

I tried nofilt.loc[nofilt['cluster_id'] == '0'] it gave me blank return, just headers.
Any help is much appreciated, thank you!


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?