Reputation: 157
I want to assign values to my variable, so that it should contain all values greater than specific value. I am using np.range
but here also we need to pass argument as np.range(start_range, end_range, Difference between two values)
.I want my variable to contain all values greater than (start_range)
I have dataframe which contains a column Score range 0-1. Say i have created a function as below :
def get_data(Data, score):
......
......
Now when I call this function , I want all the records from my Dataframe that has score more than 0.8.
Is there any other way to assign the value in range?
Upvotes: 0
Views: 1733
Reputation: 24281
I think you want to return all values from your dataframe greater than a threshold (0.8). range
is not the tool for this.
def get_data(df, score, column):
"""Return rows of Dataframe where 'column' has value greater than 'score'."""
new_df = df.loc[df[column] > score]
return new_df
>>> get_data(df, 0.8, 'Score')
Upvotes: 2