I'm working on VCF file format,after getting data in pandas dataframe i'm getting below output.
Code
df1=df['info_dict']
print df1
output-
chr1 2337185 {u'END': 2337193}
2337194 {u'IDS': u'1026660,1026661', u'CUR': u'UNKNOWN'}
2337195 {u'END': 2337293}
2337903 {u'END': 2338125}
2338126{u'IDS': u'652130,652129', u'CUR': u'KNOWN_BEN...
2338127 {u'END': 2338414}
2339871 {u'END': 2340199}
I want to only get values of IDS which is in third column.
Expected output:
chr1 2337194 '1026660,1026661'
2338126 '652130,652129'
Use .get
for get value from dict with default value None
if non match, last remove None
s by Series.dropna
:
s = df['info_dict'].apply(lambda x: x.get('IDS')).dropna()
print (s)
chr1 2337194 1026660,1026661
2338126 652130,652129
Name: col, dtype: object
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments