Mar-16-2019, 12:56 AM
Hi,
I need to refer to specific elements in Pandas Dataframe - average salaries in the column "Average". I do not need to refer to the column, I need to refer to these items separately (e.g. only 5166). As I do not know how to do it properly, I created a df with 2 rows and used min and max but it would not work if I had more rows. Is there a solution if there are more rows?
Industry 2018 Q1 ... 2018 Q4 Average
1 Total – all industries 5049 ... 5247 5166
2 Production 4823 ... 5010 4978
Thank you!
I need to refer to specific elements in Pandas Dataframe - average salaries in the column "Average". I do not need to refer to the column, I need to refer to these items separately (e.g. only 5166). As I do not know how to do it properly, I created a df with 2 rows and used min and max but it would not work if I had more rows. Is there a solution if there are more rows?
Industry 2018 Q1 ... 2018 Q4 Average
1 Total – all industries 5049 ... 5247 5166
2 Production 4823 ... 5010 4978
def comparison(industry, salary):
if industry == "production":
if salary > int(df['Average'].min()):
return "Above the average salary"
elif salary < int(df['Average'].min()):
return "Below the average salary"
elif salary == int(df['Average'].min()):
return "Average salary"
else:
if salary > int(df['Average'].max()):
return "Above the average salary"
elif salary < int(df['Average'].max()):
return "Below the average salary"
elif salary == int(df['Average'].max()):
return "Average salary" Hopefully you can advise me.Thank you!
