Python Forum

Full Version: how to parse this array with pandas?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i glad for any help because I tried without succeed



I attached link to data in array:
https://pastebin.com/WnQMnn54

thanks
netanel
I also attached relevant code:
 
def recursive_indicator(i,rec):
    li.append(f"{i} is found")
    try:
        ax=pd.DataFrame(data=i["relations"])
        for xyz in i["relations"]:
            for tti in ax.values:
                tti[3]=datetime.datetime.fromtimestamp(tti[3])
                tti[4]=datetime.datetime.fromtimestamp(tti[4])
            return (ax.to_dict())               


        
        

        if(i["relations"]==None):
            return li
        else:
            if(i==""):
                rael=[]
                #ip=ip+1
                return li 
            elif(rec>=0):
                rael=i["relations"]
                rec=rec-1
                #ip=ip+3
                if rael  == []:
                    li.append(f'{i["id"]}')
                else:

                    for xx in rael:
                        li.append(recursive_indicator(i=xx,rec=rec))
                #   ip=ip+2
                return li

                
            else:

                return li    
    bx=pd.DataFrame(data=li)
    cx=pd.DataFrame(data=bx.values[1])
    Dx=pd.DataFrame(data=cx.values[0])
    Ex=pd.DataFrame(data=Dx.values[0])
    ARREX=pd.DataFrame(data=Ex.values[0])
    tx=""
    for i in range(len(bx.value_counts())):
        tx=tx+ARREX[i]

    return f"<hr>{li}<a href='/home'>return</a>"
That's a weird array

["{'id': 'ip_address_123.123.123.123', 'indicator': '123.123.123.123', ....