Closed deeps17 closed 10 years ago
Sure, @deeps17. In the lecture we briefly talked about how you can apply functions to a column, ie:
df['new_column'] = df['column'].apply(a_function)
Here, the goal is to simplify the data set, so you have text like "text_petal_width" == short/long, etc.
Does that help?
@podopie - Ah..Got it! thanks..
Cool. An example would be:
def text_petal_length(x):
return 'long' if x > 1 else 'short'
iris['PetalLengthTXT'] = iris['PetalLength'].apply(text_petal_length)
And then you'll have a new column that is either 'long' or 'short'.
I wasn't clear on the problem stmt in this question and what I am supposed to do This is from the independent practice exercise:
Can you help clarify?