Linked Questions

0 votes
2 answers
99 views

Appending and reading list values in nested dictionaries [duplicate]

Need to check I'm understanding this right. I'm running a function that appends lists to a list in a nested dictionary. I thought I would be able to assign a variable to append and return the same ...
Dan's user avatar
  • 229
0 votes
2 answers
416 views

How can I generate an array of 8 unique numbers in python?

I'm trying to create a function that, one by one, generates 8 random numbers from 1 to 8 and adds them to an array, checking if they are unique each time before adding them. However, it doesn't work ...
Kieran Gale's user avatar
0 votes
2 answers
6k views

Python - Array goes out of bounds [duplicate]

Good day everyone, today I struggled with my code for more than an hour, just to find out that Python did not give an out of bound error. This is my summarised code: array = [] n = 0 while n < 5: ...
Matthias's user avatar
-4 votes
2 answers
321 views

Genereating all possible combinations of array (without repetition) in python

How would you get every possible combination of array below? Example for array=[1,2,3] Possible combinations are 1 2 3 1 3 2 2 1 3 2 3 1 3 2 1 3 1 2
Suchy 's user avatar
  • 11
6 votes
1 answer
142 views

Is python smart enough to replace function calls with constant result?

Coming from the beautiful world of c, I am trying understand this behavior: In [1]: dataset = sqlContext.read.parquet('indir') In [2]: sizes = dataset.mapPartitions(lambda x: [len(list(x))]).collect()...
gsamaras's user avatar
  • 72.7k
3 votes
1 answer
397 views

Is array.count() orders of magnitude slower than list.count() in Python?

Currently I am playing with Python performance, trying to speed up my programs (usually those which compute heuristics). I always used lists, trying not to get into numpy arrays. But recently I've ...
minecraftplayer1234's user avatar
3 votes
1 answer
303 views

Python and memory efficient way of importing 2d data

I'm trying to run a few scripts analyzing data with Python and I've been quickly surprised by how much RAM space it takes: My script reads two columns of integers from a file. It imports it in the ...
Learning is a mess's user avatar
1 vote
1 answer
71 views

Python: Square brackets on RHS should mean `List`, not `Array`?

I am examining example Pandas code for creating a MultiIndex: In [1]: arrays = [['bar', 'bar', 'baz', 'baz', 'foo', 'foo', 'qux', 'qux'], ...: ['one', 'two', 'one', 'two', 'one', 'two', '...
user36800's user avatar
  • 2,169
1 vote
1 answer
2k views

python: best data structure to use to store strings?

I am planning to break a long document in various strings, and save them as they are (so each string can have different length, i will not break them to strings with specific length). I was planning ...
user1006198's user avatar
  • 4,941
0 votes
1 answer
88 views

Declaring variables in Python 2.7x to avoid issues later

I am new to Python, coming from MATLAB, and long ago from C. I have written a script in MATLAB which simulates sediment transport in rivers as a Markov Process. The code randomly places circles of a ...
SurfProc's user avatar
  • 105
-1 votes
1 answer
294 views

Translate VBA array into Python

USING IDLE/Python 3.5.1 May I first of all begin by saying I am a reasonably experienced programmer in VBA but am on day 2 of Python. I assure you I have conducted many searches on this question but ...
Tom PC's user avatar
  • 11
-1 votes
1 answer
145 views

Difference beetween C arrays and Python lists [closed]

I ask this because i'm a beginner in CS and i have this doubt. So it would be nice if peeps try to explain instead of just make humor or downvote. I tought this site was for learning from others. Is ...
pietrovismara's user avatar
-2 votes
1 answer
32 views

Python arrays issue

I tried writing the code for a problem, but the module won't run. It says invalid syntax, but it's not highlighting anything. The code: http://pastebin.com/cJVNBcYE The problem: http://pastebin.com/...
user179627's user avatar
-3 votes
1 answer
270 views

Difference between array() and [] Python

I have a quick question. I would like to know if : array() is the same as [] An example: Is : [[1,2,2],[1,2,8]] Equal to : array([1,2,2],[1,2,8]) ? Could you explain the differences and examples of ...
LuckyFr's user avatar
  • 411
0 votes
0 answers
95 views

Difference between an Array and a List [duplicate]

I have values from 0-300, I must only project values >50 and <200, I can do this with both List and Array but I am forced to use a Array for this task, what is the exact difference between the ...
Kondos-_-'s user avatar

15 30 50 per page