Reputation: 1 Apprentice
- Active Posts:
- 22 (0.03 per day)
- 02-September 12
- Profile Views:
- Last Active:
- Nov 08 2014 12:07 PM
- Dream Kudos:
Posts I've Made
Posted 8 Nov 2014edit for performance:
a better way to optimize (in this case) parse_list is to use *del* instead to create a new list for each iteration:
def parse_list(_list, N, dec=0): for _ in range(dec, 0, -1): del _list[:N] # change inplace, more more efficient N -= 1 return _list[:N]
Posted 8 Nov 2014This is a classic case in which you think immediately to recursions;
ok, if you are a Lisp or Prolog or.... programmer, recursions are your best-friends />/>
also in Python you can write a tail recursion (a more efficient recursion):
# you can pass to -dec- def.arg the integer you want subtract to N.
def parse_list(_list, N, dec=0): if dec == 0: return _list[:N] return parse_list(_list[N:], N - 1, dec - 1)
but "unfortunately" />/> as Python programmer, you can easily translate it in a for loop, with an acceptable O(n) time complexity
this is the :
def parse_list(_list, N, dec=0): for _ in range(dec, 0, -1): _list = _list[N:] N -= 1 return _list[:N]
Posted 15 Oct 2014And if I want to load the csv into a big matrix, like 300000 x 10 ?
Is it possible?
if you want hold different *types*, the suitable *data structure* is a dataframe... like in R.(not a matrix)
in Python You can exploit powerful pandas pakage:
dataframe = pandas.read_csv(csv_file) # look at official doc
Posted 4 Oct 2014and...don't use *eval*, especially in this way.Never
here you can use *int* instead
Posted 23 Sep 2014but did you read what he wrote???
why you ask for help and then do not read *your hint*?
btw logic is totally wrong, and a function that *print* instead of *return an object* is vain...
- Member Title:
- New D.I.C Head
- Age Unknown
- Birthday Unknown
Mbare hasn't added any friends yet.