All Questions
19 questions
0
votes
1
answer
75
views
Convert a list of list items to dict
I have list list like this
[[], ['1.0', '1.0 (proxy)', '1.1', '1.1 (proxy)', '2.0', '2.0 (proxy)', '3.0', '3.0 (proxy)'], ['1.0', '1.0 (proxy)', '1.1', '1.1 (proxy)', '2.0', '2.0 (proxy)', '3.0', '3.0 ...
0
votes
3
answers
238
views
How to group dicts (compare dicts) based on all the keys?
I'm writing a python script which parses "n" number of xml's first and creates a dict of dict's with key-value being xml attributes (inside nested dicts).
Now, I want to group these nested dicts ...
-2
votes
3
answers
1k
views
Using zip_longest on unequal lists but repeat the last entry instead of returning None
There is an existing thread about this
Zipping unequal lists in python in to a list which does not drop any element from longer list being zipped
But it's not quite I'm after.
Instead of returning ...
0
votes
2
answers
114
views
Create lists with 3 levels, containing every combination of sub list(s) values
I am currently stuck with the following problem (I could not find solution already on here that really fitted this):
I have three lists a = [a, b, c], b = [1, 2, 3] and c = [0.1, 0.2, 0.3].
I would ...
1
vote
1
answer
420
views
Converting a string obtained from a Pandas dataframe into individual lists per line
test is a pandas dataframe converted to string.
strtest = (test.to_string())
print strtest
After conversion to string, I have the following output:
This is the first test file 98128612.12
This ...
1
vote
4
answers
2k
views
Generate all possible string from two strings keeping position in python
Given two words:
AT
TC
I want to generate all possible combinations (not sure if combination applies here) that can be produced by replacing one by one character of those two strings, as a result:
...
2
votes
1
answer
182
views
How to zip generated lists when random lists return empty, using itertools and fillvalue?
I am trying to zip together multiple lists that contain 10 values. The lists are created by an iterator. Sometimes, the lists generated contain less than 10 values or even 0 values. Thus, I sometimes ...
0
votes
2
answers
197
views
Can't merge two lists into a dictionary
I can't merge two lists into a dictionary.I tried the following :
Map two lists into a dictionary in Python
I tried all solutions and I still get an empty dictionary
from sklearn.feature_extraction ...
-1
votes
1
answer
2k
views
code debugging: 'take a list of ints between 0-9, return largest number divisible by 3'
I'm trying to understand what is wrong with my current solution.
The problem is as follows:
using python 2.7.6"
You have L, a list containing some digits (0 to 9). Write a function answer(L) which ...
1
vote
1
answer
247
views
What is the inverse function of itertools.izip in python?
I saw this, and this questions and I'd like to have the same effect, only efficiently done with itertool.izip.
From itertool.izip's documentation:
Like zip() except that it returns an iterator ...
-1
votes
2
answers
2k
views
comparing two lists of unequal length at each index
I have two lists of unequal length such as
list1 = ['G','T','C','A','G']
list2 = ['AAAAA','TTTT','GGGG','CCCCCCCC']
I want to compare these two lists at each index only ...
6
votes
2
answers
443
views
Splitting a list into uneven tuples
I'm trying to split a list of strings into a list of tuples of uneven length containing these strings, with each tuple containing strings initially separated with blank strings. Basically I'd need the ...
1
vote
1
answer
187
views
itertools combinations creates a missing pair
I created a combination hash from an array list using the following code:
all_waypoints = [item1,item2,...]
waypoint_distances = {}
for (waypoint1, waypoint2) in combinations(all_waypoints, 2):
...
4
votes
3
answers
2k
views
Get product of lists of tuples by combining tuple elements?
I have a list of tuples that I am trying to get the product of by combining the individual tuple elements.
For example:
lists = [
[(1,), (2,), (3,)],
[(4,), (5,), (6,)]
]
p = itertools....
1
vote
1
answer
86
views
Can itertools allow for list to be created from multiple lists where I set a limit to how many selections per list?
I have a list of lists that I am using itertools.product with, but I would not like to limit the selection to 1 item per list. Is there a way to allow it to limit 3 from one list, 2 from the next list,...