Jun-15-2018, 05:13 AM
(This post was last modified: Jun-15-2018, 05:13 AM by tryingtolearnpython.)
Hi everyone,
I'm very new to Python so my questions may be very basic for most of you.
I am not sure I understand the below function. The part I am having trouble understanding is:
How does Python know nacho_table is a table and not an array?
I'm very new to Python so my questions may be very basic for most of you.
I am not sure I understand the below function. The part I am having trouble understanding is:
1 2 3 |
reactions = nacho_table.column( 'Reactions' ) number_wow_reactions = np.count_nonzero(reactions = = 'Wow!' ) number_meh_reactions = np.count_nonzero(reactions = = 'Meh.' ) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
def both_or_neither(nacho_table): reactions = nacho_table.column( 'Reactions' ) number_wow_reactions = np.count_nonzero(reactions = = 'Wow!' ) number_meh_reactions = np.count_nonzero(reactions = = 'Meh.' ) if number_wow_reactions > number_meh_reactions: return 'Wow!' elif number_wow_reactions < number_meh_reactions: return 'Meh.' else : return 'Okay!' # next condition should return 'Meh.' ... # next condition should return 'Okay!' ... many_nachos = Table().with_column( 'Nachos' , np.random.choice(nachos, 250 )) many_nachos = many_nachos.with_column( 'Reactions' , many_nachos. apply (nacho_reaction, 'Nachos' )) result = both_or_neither(many_nachos) result |