<jupyter_start><jupyter_text>Create a histogram to visualize the most common salary ranges for employees.<jupyter_code>#display salaries table
salaries = pd.read_sql('select * from salaries', connection)
salaries.head()
#finding the maximum value of salary
max_salary = salaries["salary"].max()
max_salary
#finding the minimum value of salary
min_salary = salaries["salary"].min()
min_salary
#calculate gap for 6 bins
bin_value = (max_salary - min_salary)/5
bin_value

#set bin value increase by $18K for each bin
salary_df = salaries["salary"]
salary_df
#create histogram for salary
#set bins_list

bins_list = [40000,58000,76000,94000,112000,130000]
ax = salary_df.hist(bins=bins_list)

plt.grid(axis='y', alpha=0.75)
plt.xlabel('Salary Range',fontsize=15)
plt.ylabel('Frequency',fontsize=15)
plt.xticks(fontsize=15)
plt.yticks(fontsize=15)
plt.ylabel('Frequency',fontsize=15)
plt.title('Most Common Salary Range',fontsize=15)
plt.show()<jupyter_output><empty_output><jupyter_text>Create a bar chart of average salary by title.<jupyter_code>#display salaries table
salaries = pd.read_sql('select * from salaries', connection)
salaries.head()
#display titles table
titles = pd.read_sql('select * from titles', connection)
titles.head()
#display employees table
employees= pd.read_sql('select * from employees', connection)
employees.head()
#Merge salaries table and employees table
combined_df = pd.merge(salaries, employees, on="emp_no")
combined_df
#rename emp_title_id to title_id
combined_df = combined_df.rename(columns={"emp_title_id": "title_id"})
#display combined df
combined_df.head()
#combine combined df with titles table
combined_df = pd.merge(combined_df, titles, on="title_id")
combined_df
#create a dataframe group by title
salary_by_title = combined_df.groupby("title").mean()
salary_by_title
#drop emp_no column
salary_by_title = salary_by_title.drop(columns = "emp_no")
salary_by_title
# Reset Index
salary_by_title = salary_by_title.reset_index()
salary_by_title
# x_axis, y_axis & Tick Locations
x_axis = salary_by_title["title"]
ticks = np.arange(len(x_axis))
y_axis = salary_by_title["salary"]
 
# Create Bar Chart Based on Above Data
plt.bar(x_axis, y_axis, align="center", alpha=0.5)

# Create Ticks for Bar Chart's x_axis
plt.xticks(ticks, x_axis, rotation="vertical")

# Set Labels & Title
plt.ylabel("Salaries")
plt.xlabel("Titles")
plt.title("Average Salary by Title")

# Show plot
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11582381729200653, 'fraction_numerical': 0.02161500815660685, 'mean_word_length': 7.4006849315068495, 'pattern_counts': {'":': 1, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '3381', 'license': 'ADSL', 'n_tokens_mistral': 916, 'n_tokens_neox': 848, 'n_words': 212, 'path': 'bonus.ipynb', 'repo_name': 'SandraTeh/sql-challenge', 'size': '2452'}