drop non-json object rows from python dataframe column

后端 未结 3 1110
孤城傲影
孤城傲影 2021-01-22 23:43

I have a dataframe such that the column contains both json objects and strings. I want to get rid of rows that does not contains json objects.

Below is how my dataframe

3条回答
  •  清歌不尽
    2021-01-23 00:13

    df[df.applymap(np.isreal).sum(1).gt(0)]
    Out[794]: 
                                A
    2    {'a': 5, 'b': 6, 'c': 8}
    5  {'d': 9, 'e': 10, 'f': 11}
    

提交回复
热议问题