Posts

Showing posts with the label crosstab

Recreate PROC FREQ in Python

Image
Mastering Descriptive Tables in Python: A Nod to SAS's PROC FREQ Mastering Descriptive Tables in Python: A Nod to SAS's PROC FREQ The art of data analysis often begins with understanding the landscape of your dataset. In SAS, PROC FREQ has long been the de facto tool for generating descriptive tables. Python, via its Pandas library, offers comparable functionalities albeit with a different approach. This post aims to bridge the gap between SAS's PROC FREQ and Python's Pandas, focusing on generating descriptive tables that are replete with counts, row percentages, column percentages, and overall percentages. A Quick Dive into SAS's PROC FREQ Before we dive into Python, let's understand what PROC FREQ in SAS is capable of. This procedure is immensely powerful for categorical data analysis. It provides easy ways to calculate counts, percentages, and additional statistics with simple syntax. For instance, one might execute: PROC FREQ ...

Comparing DataFrames

Image
Comparing Relationships in Dataframes with Python Comparing Relationships in Dataframes with Python If you work with data, chances are you will need to compare different datasets to each other. One specific task could be to compare the relationships between categorical variables in different datasets. In this blog post, we will use Python and its powerful libraries such as Pandas and NumPy to accomplish this task. What are we trying to achieve? Imagine you have two datasets, a 'base' and a 'comparison' dataset. Each dataset has the same categorical variables, for example 'degree_type' and 'acad_degree'. You want to check if the relationship between these variables is the same in both datasets. For instance, if in the base dataset 'AAS' always corresponds to 'Associates', you want to ensure the same applies to the comparison dataset. How do we do it? We start by creating a function, let's cal...