nested-lists Questions
53
Solved
Yes, I know this subject has been covered before:
Python idiom to chain (flatten) an infinite iterable of finite iterables?
Flattening a shallow list in Python
Comprehension for flattening a seque...
Dentation asked 28/1, 2010 at 22:15
19
Solved
I created a list of lists:
>>> xs = [[1] * 4] * 3
>>> print(xs)
[[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]
Then, I changed one of the innermost values:
>>> xs[0][0] = 5
...
Burford asked 27/10, 2008 at 14:57
3
Solved
is it possible to directly select a column of all nested lists within a list?
My list is created using aggregate() with table():
AgN=aggregate(data,by=list(d$date),FUN=table,useNA="no")
AgN$x lo...
Montalvo asked 22/10, 2012 at 17:12
10
Solved
I have a list of lists:
a = [[1, 3, 4], [2, 5, 7]]
I want the output in the following format:
1 3 4
2 5 7
I have tried it the following way , but the outputs are not in the desired way:
for...
Lelalelah asked 10/8, 2016 at 11:35
4
Solved
Beginner in data manipulation in R, I struggle with multi-level nested lists.
Question: Is there a way to transform this dat0 3-levels list into the global dat1 dataframe below?
The new fulltext c...
Origen asked 19/12, 2023 at 18:1
4
Solved
Suppose, that as part of documenting your code (Javadoc) you want to indicate that the relationships between elements using deep indentation.
How can I create a nested list as:
some element
so...
Patina asked 25/6, 2011 at 15:43
1
import * as React from "react";
import { render } from "react-dom";
import {
List,
CellMeasurerCache,
CellMeasurer,
WindowScroller,
AutoSizer
} from "react-virtualize...
Engelbert asked 1/9, 2023 at 9:21
9
Solved
I'm wondering what is the best way to extract the first item of each sublist in a list of lists and append it to a new list. So if I have:
lst = [[a,b,c], [1,2,3], [x,y,z]]
And, I want to pull out...
Presently asked 31/7, 2014 at 3:21
7
Solved
names=[['Pat','Sam', np.nan, 'Tom', ''], ["Angela", np.nan, "James", ".", "Jackie"]]
values=[[1, 9, 1, 2, 1], [1, 3, 1, 5, 10]]
I have 2 lists: names and va...
Twine asked 2/5, 2023 at 6:19
6
Solved
The goal is to convert a nested list which sometimes contain missing records into a data frame. An example of the structure when there are missing records is:
mylist <- list(
list(
Hit = "...
Derision asked 3/10, 2014 at 10:46
7
I have a list of lists of strings like:
example = [["string 1", "a\r\ntest string:"],["string 1", "test 2: another\r\ntest string"]]
I'd like to replace the "\r\n" with a space (and strip off th...
Monarski asked 8/12, 2012 at 20:51
2
Solved
I need to implement a structure similar to this: example.com/folder1/folder2/folder3/../view (there can be other things at the end instead of "view")
The depth of this structure is not known, and ...
Flagg asked 2/3, 2010 at 0:40
3
Solved
I have a somewhat complicated data structure (a nested list) y, defined as:
x <- list(
list(1, "a", 2, "b", 0.1),
list(3, "c", 4, "d", 0.2),
list(5, &q...
Stovall asked 10/3, 2023 at 4:44
2
Solved
I'd like to create multilevel nested list to display the menu on the left side - - very similar as on oficial site: https://material-ui-next.com/.
data source is in JSON where for each item there's...
Syllabi asked 4/2, 2018 at 12:4
8
Solved
I am trying to get the index of an element in nested lists in python - for example [[a, b, c], [d, e, f], [g,h]] (not all lists are the same size).
I have tried using
strand_value= [x[0] for x in...
Armidaarmiger asked 26/11, 2015 at 12:15
2
Maybe I'm missing something obvious but trying to flatten a list of named lists of named lists in R (may even be more nested) into eventually one flat list. purrr and rlist seem to have tools for t...
Hypothyroidism asked 13/3, 2018 at 9:22
1
Solved
I am trying to make a python program to draw a line and turn it into a circle with an animation using pygame, yet I haven't even gotten through the drawing-the-line code. I have noticed that python...
Hutson asked 20/7, 2022 at 17:16
3
Solved
I have a nested list. Each level of this list is named (as in provided dummy example). I want to extract the names (unique) from the 2nd level of my initial list, so I will be able to use them in s...
Seismology asked 6/7, 2022 at 11:25
4
Solved
I am trying to convert a nested list of lists into a list of tuples in Python 3.3. However, it seems that I don't have the logic to do that.
The input looks as below:
>>> nested_lst = ...
Redeploy asked 21/9, 2013 at 22:21
15
Solved
I tried everything (in my knowledge) from splitting the array and joining them up together
and even using itertools:
import itertools
def oneDArray(x):
return list(itertools.chain(*x))
T...
Abjuration asked 5/7, 2013 at 9:40
2
I have a list that contains some other lists, but also contains additional objects that aren't lists such as data frames. I want to flatten this to a single list, but the usual advice (see How to f...
Tartaric asked 29/4, 2022 at 10:7
7
Solved
I just started with python and very soon wondered if indexing a nested list with a tuple was possible. Something like: elements[(1,1)]
One example where I wanted to do that was something similar t...
Volscian asked 20/5, 2015 at 5:31
2
Solved
Consider this nested list of dataframes:
df <- data.frame(x = 1:5, y = letters[1:5])
l <- list(df, list(df, df), list(df, list(df, df, list(df))), list(df), df)
How can one get from this dee...
Reneerenegade asked 22/4, 2022 at 14:2
2
Solved
I am trying to traverse a list of Lists in L Shape. For example: lShapedTraverse [[1,2,3],[4,5,6],[7,8,9]] will result in [[1,2,3,6,9],[4,5,8],[7]]
I have the following algorithm which gives ...
Leyte asked 27/3, 2022 at 1:1
4
Solved
I have a nested list, have_list. At the center is a list with four vectors of integers, a, b, c, d.
For a, b, c, d, each has a unique cutoff value. I would like to find the first positions when the...
Jelsma asked 22/3, 2022 at 12:58
1 Next >
© 2022 - 2024 — McMap. All rights reserved.