|
10 | 10 | import random
|
11 | 11 | import functions as ff
|
12 | 12 | import main_analysis as main
|
| 13 | +import os |
13 | 14 |
|
14 | 15 | #######################################
|
15 | 16 | # DATA LOADING
|
16 | 17 | #######################################
|
17 | 18 |
|
18 | 19 | st.set_page_config(layout='wide')
|
19 | 20 |
|
| 21 | +# Determine the base path |
| 22 | +base_path = os.path.dirname(__file__) |
| 23 | + |
20 | 24 | # Loading data files
|
21 |
| -df = pd.read_csv('df2020.csv') |
22 |
| -df2018 = pd.read_csv('df2018.csv') |
23 |
| -full_data2018 = pd.read_csv('survey_results_sample_2018.csv') |
24 |
| -full_data2019 = pd.read_csv('survey_results_sample_2019.csv') |
25 |
| -full_df2020 = pd.read_csv('survey_results_sample_2020.csv') |
26 |
| -df2019 = pd.read_csv('df2019.csv') |
| 25 | +df = pd.read_csv(os.path.join(base_path, 'df2020.csv')) |
| 26 | +df2018 = pd.read_csv(os.path.join(base_path, 'df2018.csv')) |
| 27 | +full_data2018 = pd.read_csv(os.path.join(base_path, 'survey_results_sample_2018.csv')) |
| 28 | +full_data2019 = pd.read_csv(os.path.join(base_path, 'survey_results_sample_2019.csv')) |
| 29 | +full_df2020 = pd.read_csv(os.path.join(base_path, 'survey_results_sample_2020.csv')) |
| 30 | +df2019 = pd.read_csv(os.path.join(base_path, 'df2019.csv')) |
27 | 31 |
|
28 | 32 | # Filter the 2020 dataframe
|
29 | 33 | df2020 = df[df['SalaryUSD'] < 200000]
|
30 | 34 |
|
31 | 35 | # Load CSS file
|
32 | 36 | def local_css(file_name):
|
33 |
| - with open(file_name) as f: |
| 37 | + css_path = os.path.join(base_path, file_name) |
| 38 | + with open(css_path) as f: |
34 | 39 | st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
|
35 | 40 |
|
36 | 41 | local_css("style.css")
|
@@ -61,7 +66,7 @@ def local_css(file_name):
|
61 | 66 | full_data2018.rename(columns={'ConvertedSalary': 'SalaryUSD'}, inplace=True)
|
62 | 67 |
|
63 | 68 | # Strip leading and trailing whitespace from all columns in df_ai
|
64 |
| -df_ai = df_ai.applymap(lambda x: x.strip() if isinstance(x, str) else x) |
| 69 | +df_ai = df_ai.apply(lambda x: x.str.strip() if x.dtype == "object" else x) |
65 | 70 |
|
66 | 71 | # Mapping for shorter versions
|
67 | 72 | short_mapping = {
|
|
0 commit comments