Skip to content

Commit

Permalink
Add data analysis file for scatter plot visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
Varshitha006 committed Oct 13, 2024
1 parent 83cd170 commit a9d860e
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions data_analysis (1).py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
"""Data analysis.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1rgZ1KKaswBXKXYF_m5svCLsk6eBzLBT9
"""

!pip install streamlit

import pandas as pd
import streamlit as st
import seaborn as sns
import matplotlib.pyplot as plt

def load_and_scatterplot(year):

file_path = f"Survey_results_sample_{year}.csv"

try:
data = pd.read_csv(file_path)
except FileNotFoundError:
st.error(f"File for the year {year} not found!")
return None



cols = ['Country', 'YearsCodePro', 'ConvertedCompYearly', 'DevType']
filtered_data = data[cols].dropna()

filtered_data['YearsCodePro'] = pd.to_numeric(filtered_data['YearsCodePro'], errors='coerce')
filtered_data = filtered_data.dropna(subset=['YearsCodePro'])
# Create a scatter plot for YearsCodePro vs ConvertedCompYearly, color-coded by DevType
st.write(f"Scatter Plot: Years of Professional Coding Experience vs Yearly Compensation for {year}")

plt.figure(figsize=(14, 8))

scatter = sns.scatterplot(
data=filtered_data,
x='YearsCodePro',
y='ConvertedCompYearly',
hue='DevType',
style='Country',
palette='deep',
s=100,
alpha=0.6
)

scatter.legend(loc='center left', bbox_to_anchor=(1, 0.5), title='Developer Type')

plt.title(f'YearsCodePro vs ConvertedCompYearly ({year}), colored by DevType', fontsize=16)
plt.xlabel('Years of Professional Coding Experience', fontsize=14)
plt.ylabel('Yearly Compensation (USD)', fontsize=14)

st.pyplot(plt)

0 comments on commit a9d860e

Please sign in to comment.