Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: help on understanding this output
Post: help on understanding this output

>>> flist = [] >>> for i in range(3): ...     flist.append(lambda: i) ... >>> [f() for f in flist]   # what will this print out?Why is the above output [2,2,2]? Thanks, L
landlord1984 General Coding Help 1 2,956 Mar-08-2017, 08:05 PM
    Thread: What does 1 do in X = np.array(df.drop(['label'], 1))?
Post: RE: What does 1 do in X = np.array(df.drop(['label...

(Feb-04-2017, 01:19 PM)buran Wrote: Actually, that is argument fo df.drop http://pandas.pydata.org/pandas-docs/sta....drop.html Arha....I need to take a rest. My eye seems not working.
landlord1984 Data Science 2 10,348 Feb-04-2017, 03:13 PM
    Thread: What does 1 do in X = np.array(df.drop(['label'], 1))?
Post: What does 1 do in X = np.array(df.drop(['label'], ...

X = np.array(df.drop(['label'], 1))I understand this code is to convert a Pandas's dataframe into a numpy array without a column labelled as "label". But what is 1 doing here? Accoding to numpy arra...
landlord1984 Data Science 2 10,348 Feb-04-2017, 01:15 PM
    Thread: Why list(dict.keys()) does not work?
Post: RE: Why list(dict.keys()) does not work?

(Feb-02-2017, 07:55 AM)wavic Wrote: my_dict = {'a':'aaa','b':'bbb','c':'ccc'} l = list(my_dict.keys()) print(l) print(my_dict.keys()) Weird....The script code works. But those in console still d...
landlord1984 General Coding Help 5 13,657 Feb-02-2017, 10:53 AM
    Thread: Why list(dict.keys()) does not work?
Post: Why list(dict.keys()) does not work?

dict={'a':'aaa','b':'bbb','c':'ccc'} list(dict.keys())Quote:TypeError                                 Traceback (most recent call last) <ipython-input-60-be97bb392967> in <module>() ----&...
landlord1984 General Coding Help 5 13,657 Feb-02-2017, 07:19 AM
    Thread: Feel hard to learn the topic about " Parsing"
Post: RE: Feel hard to learn the topic about " Parsing"

(Jan-31-2017, 12:54 PM)Ofnuts Wrote: (Jan-31-2017, 11:51 AM)landlord1984 Wrote: So far I quite enjoyed learning Python from list and class to numpy and pandas. I have practiced ~80 algorithm type ...
landlord1984 Web Scraping & Web Development 7 6,377 Feb-01-2017, 05:46 AM
    Thread: Feel hard to learn the topic about " Parsing"
Post: Feel hard to learn the topic about " Parsing"

So far I quite enjoyed learning Python from list and class to numpy and pandas. I have practiced ~80 algorithm type questions from leetcode and Hackrancker. They are nice web source for practice codin...
landlord1984 Web Scraping & Web Development 7 6,377 Jan-31-2017, 11:51 AM
    Thread: Creating 2D array without Numpy
Post: RE: Creating 2D array without Numpy

(Jan-27-2017, 09:43 AM)ichabod801 Wrote: The first way doesn't work because [[0] * n] creates a mutable list of zeros once. Then when the second *n copies the list, it copies references to first lis...
landlord1984 Data Science 3 35,895 Jan-27-2017, 05:29 PM
    Thread: Creating 2D array without Numpy
Post: Creating 2D array without Numpy

I want to create a 2D array and assign one particular element. The second way below works. But the first way doesn't. I am curious to know why the first way does not work. Is there any way to create a...
landlord1984 Data Science 3 35,895 Jan-27-2017, 08:57 AM
    Thread: Where is the loophole in my code
Post: RE: Where is the loophole in my code

Thanks for the suggestions on efficiency matters. I will spend some time focusing on efficiency stuff. I realized there are better ways to do this. I just curious about what is wrong by this stupid wa...
landlord1984 Homework 15 10,129 Jan-27-2017, 12:49 AM
    Thread: map function
Post: RE: map function

(Jan-27-2017, 12:39 AM)micseydel Wrote: Ok, it sounds like you're using Python 3. Generators are lazy, so until you do something with them they represent more potential than work done. map() and com...
landlord1984 General Coding Help 5 4,670 Jan-27-2017, 12:46 AM
    Thread: Where is the loophole in my code
Post: RE: Where is the loophole in my code

What do you mean homework from OP? I am not a student. I am learning Python by myself. I am practicing by coding those questions from online challenges. This is a question from Leetcode. My codes pas...
landlord1984 Homework 15 10,129 Jan-27-2017, 12:29 AM
    Thread: map function
Post: RE: map function

(Jan-26-2017, 11:55 PM)micseydel Wrote: map(print,[1,2,3])Output is <map at 0x1099dc160> I know the map function returns a generator, but shouldn't it execute the function print?
landlord1984 General Coding Help 5 4,670 Jan-27-2017, 12:24 AM
    Thread: map function
Post: map function

map(print,[1,2,3])I thought above code should print individual element, but it does not work. Why map function does not work here? L
landlord1984 General Coding Help 5 4,670 Jan-26-2017, 11:44 PM
    Thread: Access 2D array problem
Post: Access 2D array problem

I got: SortedArray2D= [['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h', 'i', 'j'], ['k', 'l', 'm', 'n', 'o'], ['p', 'q', 'r', 's', 't'], ['u', 'v', 'w', 'x', 'y']]print(SortedArray2D[:][1])gives Quote:['f'...
landlord1984 Data Science 1 3,330 Jan-23-2017, 07:57 AM
    Thread: Where is the loophole in my code
Post: Where is the loophole in my code

Question is: Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. For example, given nums = [0, 1, 0, 3, 12], after c...
landlord1984 Homework 15 10,129 Jan-22-2017, 04:05 AM
    Thread: what is [o,]?
Post: RE: what is [o,]?

(Jan-21-2017, 09:15 PM)ichabod801 Wrote: Note that brackets [] define a list, and parentheses () define a tuple. A comma is not needed for a one item list, [o] works fine. But a comma is needed for ...
landlord1984 General Coding Help 6 5,515 Jan-22-2017, 03:01 AM
    Thread: what is [o,]?
Post: RE: what is [o,]?

(Jan-21-2017, 08:48 AM)landlord1984 Wrote: I am studying following teaching me about composition of class objects. What is o doing here? def print_all_2(self): def gen(o): lA...
landlord1984 General Coding Help 6 5,515 Jan-21-2017, 07:03 PM
    Thread: what is [o,]?
Post: what is [o,]?

I am studying following teaching me about composition of class objects. What is o doing here?     def print_all_2(self):         def gen(o):             lAll = [o,]from following codes: class Node(ob...
landlord1984 General Coding Help 6 5,515 Jan-21-2017, 08:48 AM
    Thread: Why Python's standard library is hard to read?
Post: Why Python's standard library is hard to read?

Are you guys generally search and read from here: https://docs.python.org/3/library/functions.html#filter  ? I found it is hard to read. Maybe it is my personal feeling. But I can easily read C++ and...
landlord1984 Data Science 2 4,167 Jan-20-2017, 10:41 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020