nested

Converting nested JSON into a flattened DataFrame

Converting nested JSON into a flattened DataFrame Question: I have a data load in nested json format and I want to get a nested dataframe { "page_count": 21, "page_number": 1, "page_size": 300, "total_records": 6128, "registrants": [ { "id": "23lnTNqyQ3qkthfghjgkk", "first_name": "HUGO", "last_name": "MACHA ILLEN", "email": "[email protected]", "address": "", "city": "", "country": "", "zip": "", "state": …

Total answers: 1

Variable number of nested for loops in Python

Variable number of nested for loops in Python Question: I am having trouble getting this to work and any help would be greatly appreciated. I want to have a variable number of nested for loops for the following code. The idea is to write every combination possible to a csv file. here is my code: …

Total answers: 2

Any depth nested dict to pandas dataframe

Any depth nested dict to pandas dataframe Question: I’ve been fighting to go from a nested dictionary of depth D to a pandas DataFrame. I’ve tried with recursive function, like the following one, but my problem is that when I’m iterating over a KEY, I don’t know what was the pervious key. I’ve also tried …

Total answers: 2

How to distance between all points in list?

How to distance between all points in list? Question: I am plotting random points on a graph. I want to find the Eucildean distance from every point to another in a list. Previous result/attempt can be viewed here I generate 4 random numbers between 0 and 10 for the x and y coordinates, and then …

Total answers: 2

I want to loop this format using python

I want to loop this format using python Question: I have 3 lists a = ["1", "2", "3", "4", "5", "6"] b = [‘a’, ‘b’, ‘c’] c = ["13", "14"] and the format is: 1 3 a 2 13 b 3 13 c 4 14 a 5 14 b 6 14 c How do I …

Total answers: 2

Change value of python nested dictionary with variable path?

Change value of python nested dictionary with variable path? Question: How can I pass a dictionary path as an argument? I thought maybe it had something to do with *args or **kwargs but I didn’t understand how to use them for this dictionary = { ‘key1’: { ‘attribute1’: ‘green’, }, ‘attribute2’: 5 } def SaveToFile(target, …

Total answers: 1

Loop Through Two Dataframe Columns to Create Key-Value Pairs For Value Dictionaries Nested Inside A Dictionary Nested Inside Another Dictonary

Loop Through Two Dataframe Columns to Create Key-Value Pairs For Value Dictionaries Nested Inside A Dictionary Nested Inside Another Dictonary Question: I want to create a metadata variable based on my input dataset’s columns using dictionaries. Specifically, I want the metadata variable to have exactly this structure and values: metadata = { ‘fields’: { ‘id’: …

Total answers: 1

How to Write a Nested For Loop in One Line Python with File Url and File Name

How to Write a Nested For Loop in One Line Python with File Url and File Name Question: data = json.dumps({‘conf’:{a:b for a in table_name for b in file_url}}) print(data) I have 2 files in file_url. sales_dy_20221022.csv sales_wk_20221022 I have 2 table names in table_name sales_dy sales_wk If I write the code like the above …

Total answers: 1