# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3 (ipykernel)
#     language: python
#     name: python3
# ---

# ## School Survey
#
# This data analysis is created for the purpose of analyzing how students in different schools like in person-classes and how they like their professors and In person class preference (Yes or No) and How do you like school so far (1-5).
# The final goal of this project is to find out the correlation between these four variables.

# ## Step 1
#
# Import packages that have the functions and resources that I need and read my dataset.

# +
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

df = pd.read_csv('School Survey.csv')
# -

# ## Step 2 
#
# I read the first five rows of my data to give me an overall idea of what to do and what I have to do later in the program.

df.head()

# ## Step 3
#
# I print out the length of my data.

print(len(df))
(df['In person class preference (Yes or No)'].value_counts())

# ## Step 4
#
# I print out my dataframe type.

print(type(df))

# ## Step 5
#
# I print out all the data in "School" column.

df['School']

# ## Practice Step
#
# I print out the dataframe type for School.

print(type(df['School']))

# ## Practice Step
#
# I print out first data in School column.

df['School'][0]

# ## Step 6
#
# I print out every data type that I have in my dataset

for col in df.columns:
    print(col, type(df[col][0]))

# ## Step 7
#
# I print out the descriptive statistics for my "How do you like school so far (1-5)" and	"How do you like your professors so far (1-5)" data. This step intends to give me a big picture of how the graphs might looks like later in my program and my dataset's center, range, and spread.

df.describe()

# ## Step 8
#
# I print out how many students in different schools had respond to my survey. This gives me a big idea of the distribution of my dataset in different schools.

df["School"].value_counts()

# ## Step 9
#
# I create a histogram for my "How do you like school so far (1-5)" Variable to see how many studednts like the school so far in different levels. 

df.hist(column = 'How do you like school so far (1-5)')
plt.title('How do you like school so far (1-5)', fontsize = 20)
plt.ylabel('Numbers of Observation', fontsize = 20)
plt.xlabel('Score', fontsize = 20)
plt.show()

# ## Practice Step
#
# I use a fucntion to replace all the Scores in the Restaurant Inspection to 100.

df[df['Score'] == 100]

# ## Practice Step
#
# I use a fucntion to replace all the 'Hwy 290 E\nAustin TX  78723' in the Restaurant Inspection to '78723'.

df.loc[df['Zip Code'] == 'Hwy 290 E\nAustin TX  78723'] = '78723'


# ## Practice Step
#
# I use a fucntion to replace all the '6\nAustin, TX  78741' in the Restaurant Inspection to '78741'.

df.loc[df['Zip Code'] == '6\nAustin, TX  78741'] = '78741'

# ## Step 10 
#
# I create a variable that queals to the counts of the number of the data "How do you like your professors so far (1-5)". 
# Then I use this variable to vreate a bar plot.

professor_score_counts = df['How do you like your professors so far (1-5)'].value_counts()

plt.rcParams["figure.figsize"] = (20,10)
professor_score_counts.plot.bar()
plt.title('How do you like your professors', fontsize = 20)
plt.xlabel('Score', fontsize = 20)
plt.ylabel('Number of Observation', fontsize = 20)

# ## Step 11 (Final Step 1)
#
# The Goal of this project is meant to find out the correlation between 'How do you like your professors so far (1-5)' and 'How do you like school so far (1-5)', so I made a scatter plot graph using different colors with a line of regression.

# +
x = df['How do you like your professors so far (1-5)']
y = df['How do you like school so far (1-5)']
colors = []

for i in range(121):
    colors = colors + [i]
    
plt.title('Correlation of likeness to professors and to school', fontsize = 20)
plt.xlabel('How do you like your professors so far (1-5)', fontsize = 20)
plt.ylabel('How do you like school so far (1-5)', fontsize = 20)
plt.scatter(x, y, s=100, c=colors, edgecolor='black', linewidth=1, alpha=0.75)
m, b = np.polyfit(x, y, 1)
plt.plot(x, m*x + b)
cbar = plt.colorbar()
cbar.set_label('Stisfaction')
# -

# ## Failed Step
#
# I try to create the barchart later shown with my dataset in the excel itself but failed, if possible please tell me how I can make this program run.

# +
x = df['How do you like school so far (1-5)']
y = df['In person class preference (Yes or No)']
yes = []
no = []
for i in range(df['In person class preference (Yes or No)'].size):
    if df['In person class preference (Yes or No)'][i] == "Yes":
        yes.append('Yes')
    else:
        no.append("No")

    

plt.bar(x, yes)
plt.bar(x, no, bottom = yes_series)

'''
for i in range (121):
    if 'In person class preference (Yes or No)' == 'Yes':
        yes.append(df['In person class preference (Yes or No)'][i]) 
        
    else:
        no.append(df['In person class preference (Yes or No)'][i])

        
        

plt.bar(x, yes)
plt.bar(x, no)
plt.xlabel('How do you like school so far (1-5)')
plt.ylabel('In person class preference (Yes or No)')


x = []
y = []
for i in range (121):
    if df['How do you like school so far (1-5)'] == 1
    

print(df['In person class preference (Yes or No)'] == "Yes")
'''

# -

# ## Step 11 (Final Step 2) (Please tell me if there is another way to do create this graph)
#
# The second Goal of this project is meant to find out the correlation between 'In person class preference (Yes or No)' and 'How do you like school so far (1-5)', so I made a stacked bar plot graph using different colors.

# +
x = [1, 2, 3, 4, 5]

yes = [0,0,0,0,0]
no = [0,0,0,0,0]
for i in range(121):
    for j in range(5):
        if df["How do you like school so far (1-5)"][i] == j+1:
            if df["In person class preference (Yes or No)"][i] == "Yes":
                yes[j] += 1
            else:
                no[j] += 1
    
plt.bar(x, yes)
plt.bar(x, no, bottom=yes)
plt.title("In-person Preference VS How Student like School", fontsize = 20)
plt.legend(["Yes", "No"], prop={'size': 40})
plt.xlabel('How do you like school so far (1-5)', fontsize = 20)
plt.ylabel('In person class preference (Yes or No)', fontsize = 20)
# -

# ## Conclusion
#
# In conclusion, how students like their professors is strongly correlated to how they like school so far and students who prefer in person classes is also more likely to enojoy their school life so far
#

StarcoderdataJupyterScriptsDedupFiltered