0

Need help

i get this error: File "file0.py", line 1 Response rate¶ ^ SyntaxError: invalid character in identifier on: Response rate¶ import pandas as pd # create a dataframe with the response rate data response_rate_data = {'Response rate': ['Returned', 'Not returned', 'Total'], 'Frequency': [400, 0, 400], 'Percent': [100, 0, 100]} df_response_rate = pd.DataFrame(response_rate_data) # print the dataframe print(df_response_rate) Response rate Frequency Percent 0 Returned 400 100 1 Not returned 0 0 2 Total 400 100 Gender of respondents import pandas as pd # create a dataframe with the gender data gender_data = {'Gender': ['Male', 'Female', 'Total'], 'Frequency': [213, 187, 400], 'Percent': [53, 47, 100]} df_gender = pd.DataFrame(gender_data) # print the dataframe print(df_gender) Gender Frequency Percent 0 Male 213 53 1 Female 187 47 2 Total 400 100 Distribution of Respondents Age import pandas as pd import matplotlib.pyplot as plt # create a dataframe with the age data age_data = {'Age': ['18-25', '26-35', '36-45', '46-55', '56-65'], 'Frequency': [176, 124, 40, 52, 4], 'Percent': [44, 31.33, 10, 13.33, 1.3]} df_age = pd.DataFrame(age_data) # print the dataframe print(df_age) # create a histogram to visualize the distribution of respondents' age plt.hist(df_age['Age'], weights=df_age['Percent']) plt.xlabel('Age') plt.ylabel('Percent') plt.title('Distribution of Respondents\' Age') plt.show() Age Frequency Percent 0 18-25 176 44.00 1 26-35 124 31.33 2 36-45 40 10.00 3 46-55 52 13.33 4 56-65 4 1.30 years as a bank client import pandas as pd # create a dataframe with the time data time_data = {'Time': ['5 years and below', '6-10 years', '10-20 years', 'Over 20 years', 'Total'], 'Frequency': [88, 187, 80, 45, 400],

27th Mar 2023, 8:11 AM
Gilbert
2 Réponses
+ 5
Gilbert , there are 2 issues: > the code you provided contains real python code, as well as also *printed output data*. the code has to be cleaned by either deleting the output data or by making them a comment. > there are also some other lines in the code that should be marked as a comment, as they are not a valid python code. > the code also tries to open a *csv* file which we don't have, so the programm is crashing.
27th Mar 2023, 2:59 PM
Lothar
Lothar - avatar
27th Mar 2023, 10:30 AM
Gilbert