Python Forum
how to parse this array with pandas?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to parse this array with pandas?
#1
i glad for any help because I tried without succeed



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

thanks
netanel
Larz60+ write May-18-2022, 03:57 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
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>"
Reply
#3
That's a weird array

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python convert csv to json with nested array without pandas terrydidi 2 9,565 Jan-12-2019, 02:25 AM
Last Post: terrydidi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020