import pandas as pd
import numpy as np
file_name_string = 'C:/Users/Charles Kelly/Desktop/Exercise Files/02_07/Begin/EmployeesWithGrades.xlsx'
employees_df = pd.read_excel(file_name_string, 'Sheet1', index_col=None, na_values=['NA'])

employees_df

"""
Explanation: Categorical Data
Categoricals are a pandas data type, which correspond to categorical variables in statistics: a variable, which can take
on only a limited, and usually fixed, number of possible values (categories; levels in R). Examples are gender, social
class, blood types, country affiliations, observation time or ratings via Likert scales.
In contrast to statistical categorical variables, categorical data might have an order (e.g. ‘strongly agree’ vs ‘agree’ or
‘first observation’ vs. ‘second observation’), but numerical operations (additions, divisions, ...) are not possible.
All values of categorical data are either in categories or np.nan. Order is defined by the order of categories, not lexical
order of the values.
documentation: http://pandas.pydata.org/pandas-docs/stable/categorical.html
End of explanation
"""


employees_df["Grade"] = employees_df["Grade"].astype("category")

"""
Explanation: Change data type
change data type for "Grade" column to category
documentation for astype(): http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.astype.html
End of explanation
"""


employees_df["Grade"].cat.categories = ["excellent", "good", "acceptable", "poor", "unacceptable"]

"""
Explanation: Rename the categories
Rename the categories to more meaningful names (assigning to Series.cat.categories is inplace)
End of explanation
"""


employees_df

"""
Explanation: Values in data frame have not changed
End of explanation
"""


employees_df.groupby('Grade').count()

"""
Explanation: tabulate Department, Name, and YearsOfService, by Grade
End of explanation
"""


