Trying to push the contents of objects nested inside objects to an array (JavaScript)

Advertisements When having objects nested inside objects I can’t loop through them with a regular for in loop. I googled and found I have to make a recursive function that would check if the property is an object. I wrote a recursive function like this: ` function isObject(value){ return (typeof(value)===’object’); } “ function listToArray(list){ let… Read More Trying to push the contents of objects nested inside objects to an array (JavaScript)

How can I make this programme format the string properly? PHP – Nested For Loop

Advertisements <?php $list = [‘a’, ‘b’, ‘c’]; $count = [1, 3, 5]; function stringFormatter($c, $i) { return "Char is $c & Int is $i"; } for ($i = 0; i < $list; $i++) { for ($j = 0; $j < $count; $j++) { $string = stringFormatter($list[$i], $count[$j]); print $string; } } ?> This is sample… Read More How can I make this programme format the string properly? PHP – Nested For Loop

How to replace the values of nested lists stored in python dataframe?

Advertisements I have the following dataframe data = [[[[[1, 2, 0], [1]],[[1, 2], [4]]], [[[[1, 2], [4]]]], [[[1]]]], [[[[1, 2, 0], [1]],[[1, 2], [4]]], [[[[1, 2], [4]]]], [[[1]]]]] df = pd.DataFrame(data) Also, I have a second dataframe df2: data2 = [[1, 10], [1, 15], [1, 14], [1, 20], [1, 18]] df2 = pd.DataFrame(data2, columns=[‘dir’, ‘line’])… Read More How to replace the values of nested lists stored in python dataframe?

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

Advertisements 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 I get the result below. "conf": { "sales_dy": "sales_dy_20221022.csv", "sales_wk": "sales_dy_20221022.csv" } How can I change the… Read More How to Write a Nested For Loop in One Line Python with File Url and File Name

Create a pandas dataframe from a nested json file

Advertisements I have the following json file: { "data": { "start_date": "2022-10-01", "end_date": "2022-10-04", "cur": "EUR", "prizes": { "2022-10-01": { "coffee": 0.1448939471560284, "usd": 1 }, "2022-10-02": { "coffee": 0.14487923291390148, "usd":1 }, "2022-10-03": { "coffee": 0.1454857922753868, "usd": 1 } } } } I want to create a dataframe which looks like this, (so without the usd… Read More Create a pandas dataframe from a nested json file

How can i calculate the sum of numbers in a nested dict. in python

Advertisements How can i calculate the sum or total points of numbers of this nested dict. in python i tried alot of things and it didn’t work all time get the last value in the loop not every grade or value. ……………………………………………………………………………………………………………………………………………………………………………………………………………………………………………… # Input students = { "Ahmed": { "Math": "A", "Science": "D", "Draw": "B",… Read More How can i calculate the sum of numbers in a nested dict. in python