1

I am trying to filter this dataframe based on some inputs from a user. This is my original dataframe - enter image description here

I have created a function that takes 3 arguments and creates a subset of this dataframe. This is the function I created -

def subset(posting_type, level, job_category):
  df_subset = df_filtered[(df_filtered['posting_type'] == 'posting_type') & (df_filtered['level'] == 'level') & (df_filtered['job_category'] == 'job_category')]
  return df_subset

I am calling this function and passing 3 parameters and am expecting to get the values which meet this filter.

subset('Internal', '01' ,'Administration & Human Resources')

But I am not getting any result. I am getting only this output. How can I get the desired value?

enter image description here

1 Answer 1

1

Your looking for equality to a string literal not to the variable e.g. 'posting_type' versus posting_type

def subset(posting_type, level, job_category):
  df_subset = df_filtered[(df_filtered['posting_type'] == posting_type) & (df_filtered['level'] == level) & (df_filtered['job_category'] == job_category)]
  return df_subset
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.