Mbare's Profile User Rating: -----

Reputation: 1 Apprentice
Group:
Members
Active Posts:
22 (0.03 per day)
Joined:
02-September 12
Profile Views:
547
Last Active:
User is offline Nov 08 2014 12:07 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   Mbare has not set their status

Posts I've Made

  1. In Topic: looping over a list

    Posted 8 Nov 2014

    edit 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]
    
    
  2. In Topic: looping over a list

    Posted 8 Nov 2014

    This 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]
    
    
  3. In Topic: seach into csv column then return the row

    Posted 15 Oct 2014

    View PostmarcoE, on 14 October 2014 - 08:15 AM, said:

    And 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
  4. In Topic: Trouble with Functions

    Posted 4 Oct 2014

    and...don't use *eval*, especially in this way.Never
    here you can use *int* instead
  5. In Topic: A little support fo recursion

    Posted 23 Sep 2014

    but 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...

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Mbare hasn't added any friends yet.

Comments

Mbare has no profile comments yet. Why not say hello?