qdesc 0.1.9__py3-none-any.whl → 0.1.9.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of qdesc might be problematic. Click here for more details.

qdesc/__init__.py CHANGED
@@ -22,19 +22,17 @@ def desc(df):
22
22
  result = anderson(df[column])
23
23
  statistic = result.statistic
24
24
  critical_values = result.critical_values
25
- # Only select the 5% and 1% significance levels
25
+ # Only select the 5% levels
26
26
  selected_critical_values = {
27
- '5% crit_value': critical_values[2], # 5% critical value
28
- '1% crit_value': critical_values[4] # 1% critical value
27
+ '5% crit_value': critical_values[2]
29
28
  }
30
29
  # Store the results in a dictionary
31
30
  results[column] = {
32
31
  'AD_stat': statistic,
33
- **selected_critical_values # Add critical values for 5% and 1% levels
32
+ **selected_critical_values # Add critical values for 5%
34
33
  }
35
34
  # Convert the results dictionary into a DataFrame
36
35
  anderson_df = pd.DataFrame.from_dict(results, orient='index')
37
-
38
36
  xl = x.iloc[:, :4]
39
37
  xr = x.iloc[:, 4:]
40
38
  x_df = np.round(pd.concat([xl, mad_df, xr, anderson_df], axis=1),2)
@@ -60,8 +58,7 @@ def grp_desc(df, numeric_col, group_col):
60
58
  'min': np.nan,
61
59
  'max': np.nan,
62
60
  'anderson_stat': np.nan,
63
- 'crit_5%': np.nan,
64
- 'crit_1%': np.nan
61
+ 'crit_5%': np.nan
65
62
  }
66
63
  else:
67
64
  ad_result = anderson(data, dist='norm')
@@ -74,15 +71,15 @@ def grp_desc(df, numeric_col, group_col):
74
71
  'mad': median_abs_deviation(data),
75
72
  'min': data.min(),
76
73
  'max': data.max(),
77
- 'anderson_stat': ad_result.statistic,
74
+ 'AD_stat': ad_result.statistic,
78
75
  'crit_5%': ad_result.critical_values[2], # 5% is the third value
79
- 'crit_1%': ad_result.critical_values[3], # 1% is the fourth value
80
76
  }
81
77
  results.append(stats)
82
78
  return np.round(pd.DataFrame(results),2)
83
79
 
84
80
  def freqdist(df, column_name):
85
81
  import pandas as pd
82
+ import numpy as np
86
83
  if column_name not in df.columns:
87
84
  raise ValueError(f"Column '{column_name}' not found in DataFrame.")
88
85
 
@@ -91,16 +88,17 @@ def freqdist(df, column_name):
91
88
 
92
89
  freq_dist = df[column_name].value_counts().reset_index()
93
90
  freq_dist.columns = [column_name, 'Count']
94
- freq_dist['Percentage'] = (freq_dist['Count'] / len(df)) * 100
91
+ freq_dist['Percentage'] = np.round((freq_dist['Count'] / len(df)) * 100,2)
95
92
  return freq_dist
96
93
 
97
94
 
98
95
  def freqdist_a(df, ascending=False):
99
96
  import pandas as pd
97
+ import numpy as np
100
98
  results = []
101
99
  for column in df.select_dtypes(include=['object', 'category']).columns:
102
100
  frequency_table = df[column].value_counts()
103
- percentage_table = df[column].value_counts(normalize=True) * 100
101
+ percentage_table = np.round(df[column].value_counts(normalize=True) * 100,2)
104
102
 
105
103
  distribution = pd.DataFrame({
106
104
  'Column': column,
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.4
2
+ Name: qdesc
3
+ Version: 0.1.9.2
4
+ Summary: Quick and Easy way to do descriptive analysis.
5
+ Author: Paolo Hilado
6
+ Author-email: datasciencepgh@proton.me
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENCE.txt
9
+ Requires-Dist: pandas
10
+ Requires-Dist: numpy
11
+ Requires-Dist: scipy
12
+ Requires-Dist: seaborn
13
+ Requires-Dist: matplotlib
14
+ Requires-Dist: statsmodels
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: description
18
+ Dynamic: description-content-type
19
+ Dynamic: license-file
20
+ Dynamic: requires-dist
21
+ Dynamic: summary
22
+
23
+ # qdesc - Quick and Easy Descriptive Analysis
24
+ ![Package Version](https://img.shields.io/badge/version-0.1.9.2-pink)
25
+ ![Python Version](https://img.shields.io/badge/python-3.8%2B-blue)
26
+ ![License: GPL v3.0](https://img.shields.io/badge/license-GPL%20v3.0-blue)
27
+
28
+ ## Installation
29
+ ```sh
30
+ pip install qdesc
31
+ ```
32
+
33
+ ## Overview
34
+ Qdesc is a package for quick and easy descriptive analysis. It is a powerful Python package designed for quick and easy descriptive analysis of quantitative data. It provides essential statistics like mean and standard deviation for normal distribution and median and raw median absolute deviation for skewed data. With built-in functions for frequency distributions, users can effortlessly analyze categorical variables and export results to a spreadsheet. The package also includes a normality check dashboard, featuring Anderson-Darling statistics and visualizations like histograms and Q-Q plots. Whether you're handling structured datasets or exploring statistical trends, qdesc streamlines the process with efficiency and clarity.
35
+
36
+ ## Creating a sample dataframe
37
+ ```python
38
+ import pandas as pd
39
+ import numpy as np
40
+
41
+ # Create sample data
42
+ data = {
43
+ "Age": np.random.randint(18, 60, size=15), # Continuous variable
44
+ "Salary": np.random.randint(30000, 120000, size=15), # Continuous variable
45
+ "Department": np.random.choice(["HR", "Finance", "IT", "Marketing"], size=15), # Categorical variable
46
+ "Gender": np.random.choice(["Male", "Female"], size=15), # Categorical variable
47
+ }
48
+ # Create DataFrame
49
+ df = pd.DataFrame(data)
50
+ ```
51
+
52
+ ## qd.desc Function
53
+ The function qd.desc(df) generates the following statistics:
54
+ * count - number of observations
55
+ * mean - measure of central tendency for normal distribution
56
+ * std - measure of spread for normal distribution
57
+ * median - measure of central tendency for skewed distributions or those with outliers
58
+ * MAD - measure of spread for skewed distributions or those with outliers; this is manual Median Absolute Deviation (MAD) which is more robust when dealing with non-normal distributions.
59
+ * min - lowest observed value
60
+ * max - highest observed value
61
+ * AD_stat - Anderson - Darling Statistic
62
+ * 5% crit_value - critical value for a 5% Significance Level
63
+ * 1% crit_value - critical value for a 1% Significance Level
64
+
65
+ ```python
66
+ import qdesc as qd
67
+ qd.desc(df)
68
+
69
+ | Variable | Count | Mean | Std Dev | Median | MAD | Min | Max | AD Stat | 5% Crit Value |
70
+ |----------|-------|-------|---------|--------|-------|-------|--------|---------|---------------|
71
+ | Age | 15.0 | 37.87 | 13.51 | 38.0 | 12.0 | 20.0 | 59.0 | 0.41 | 0.68 |
72
+ | Salary | 15.0 | 72724 | 29483 | 67660 | 26311 | 34168 | 119590 | 0.40 | 0.68 |
73
+ ```
74
+
75
+
76
+
77
+ ## qd.grp_desc Function
78
+ This function, qd.grp_desc(df, "Continuous Var", "Group Var") creates a table for descriptive statistics similar to the qd.desc function but has the measures
79
+ presented for each level of the grouping variable. It allows one to check whether these measures, for each group, are approximately normal or not. Combining it
80
+ with qd.normcheck_dashboard allows one to decide on the appropriate measure of central tendency and spread.
81
+
82
+ ```python
83
+ import qdesc as qd
84
+ qd.grp_desc(df, "Salary", "Gender")
85
+
86
+ | Gender | Count | Mean - | Std Dev | Median | MAD | Min | Max | AD Stat | 5% Crit Value |
87
+ |---------|-------|-----------|-----------|----------|----------|--------|---------|---------|---------------|
88
+ | Female | 7 | 84,871.14 | 32,350.37 | 93,971.0 | 25,619.0 | 40,476 | 119,590 | 0.36 | 0.74 |
89
+ | Male | 8 | 62,096.12 | 23,766.82 | 60,347.0 | 14,278.5 | 34,168 | 106,281 | 0.24 | 0.71 |
90
+ ```
91
+
92
+
93
+ ## qd.freqdist Function
94
+ Run the function qd.freqdist(df, "Variable Name") to easily create a frequency distribution for your chosen categorical variable with the following:
95
+ * Variable Levels (i.e., for Sex Variable: Male and Female)
96
+ * Counts - the number of observations
97
+ * Percentage - percentage of observations from total.
98
+
99
+ ```python
100
+ import qdesc as qd
101
+ qd.freqdist(df, "Department")
102
+
103
+ | Department | Count | Percentage |
104
+ |------------|-------|------------|
105
+ | IT | 5 | 33.33 |
106
+ | HR | 5 | 33.33 |
107
+ | Marketing | 3 | 20.00 |
108
+ | Finance | 2 | 13.33 |
109
+ ```
110
+
111
+
112
+
113
+ ## qd.freqdist_a Function
114
+ Run the function qd.freqdist_a(df, ascending = FALSE) to easily create frequency distribution tables, arranged in descending manner (default) or ascending (TRUE), for all the categorical variables in your data frame. The resulting table will include columns such as:
115
+ * Variable levels (i.e., for Satisfaction: Very Low, Low, Moderate, High, Very High)
116
+ * Counts - the number of observations
117
+ * Percentage - percentage of observations from total.
118
+
119
+ ```python
120
+ import qdesc as qd
121
+ qd.freqdist_a(df)
122
+
123
+ | Column | Value | Count | Percentage |
124
+ |------------|----------|-------|------------|
125
+ | Department | IT | 5 | 33.33% |
126
+ | Department | HR | 5 | 33.33% |
127
+ | Department | Marketing| 3 | 20.00% |
128
+ | Department | Finance | 2 | 13.33% |
129
+ | Gender | Male | 8 | 53.33% |
130
+ | Gender | Female | 7 | 46.67% |
131
+ ```
132
+
133
+
134
+
135
+ ## qd.freqdist_to_excel Function
136
+ Run the function qd.freqdist_to_excel(df, "Filename.xlsx", ascending = FALSE ) to easily create frequency distribution tables, arranged in descending manner (default) or ascending (TRUE), for all the categorical variables in your data frame and SAVED as separate sheets in the .xlsx File. The resulting table will include columns such as:
137
+ * Variable levels (i.e., for Satisfaction: Very Low, Low, Moderate, High, Very High)
138
+ * Counts - the number of observations
139
+ * Percentage - percentage of observations from total.
140
+
141
+ ```python
142
+ import qdesc as qd
143
+ qd.freqdist_to_excel(df, "Results.xlsx")
144
+
145
+ Frequency distributions written to Results.xlsx
146
+ ```
147
+
148
+ ## qd.normcheck_dashboard Function
149
+ Run the function qd.normcheck_dashboard(df) to efficiently check each numeric variable for normality of its distribution. It will compute the Anderson-Darling statistic and create visualizations (i.e., qq-plot, histogram, and boxplots) for checking whether the distribution is approximately normal.
150
+
151
+ ```python
152
+ import qdesc as qd
153
+ qd.normcheck_dashboard(df)
154
+ ```
155
+ ![Descriptive Statistics](https://raw.githubusercontent.com/Dcroix/qdesc/refs/heads/main/qd.normcheck_dashboard.png)
156
+
157
+
158
+ ## License
159
+ This project is licensed under the GPL-3 License. See the LICENSE file for more details.
160
+
161
+ ## Acknowledgements
162
+ Acknowledgement of the libraries used by this package...
163
+
164
+ ### Pandas
165
+ Pandas is distributed under the BSD 3-Clause License, pandas is developed by Pandas contributors. Copyright (c) 2008-2024, the pandas development team All rights reserved.
166
+ ### NumPy
167
+ NumPy is distributed under the BSD 3-Clause License, numpy is developed by NumPy contributors. Copyright (c) 2005-2024, NumPy Developers. All rights reserved.
168
+ ### SciPy
169
+ SciPy is distributed under the BSD License, scipy is developed by SciPy contributors. Copyright (c) 2001-2024, SciPy Developers. All rights reserved.
170
+
171
+
172
+
173
+
174
+
@@ -0,0 +1,6 @@
1
+ qdesc/__init__.py,sha256=MalRpouno6XdakUDspmBU1QZB8oW542rjgFohcinIJM,7933
2
+ qdesc-0.1.9.2.dist-info/licenses/LICENCE.txt,sha256=xdFo-Rt6I7EP7C_qrVeIBIcH_7mRGUh8sciJs2R8VmY,9684
3
+ qdesc-0.1.9.2.dist-info/METADATA,sha256=xoVuLdeUcRqiMhswRM8FOjcA7criZW7kY_uq01R3tTs,7794
4
+ qdesc-0.1.9.2.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
5
+ qdesc-0.1.9.2.dist-info/top_level.txt,sha256=JuSs1wWRGN77DVuq-SX-5P7m_mIZF0ikEVgPTBOrHb0,6
6
+ qdesc-0.1.9.2.dist-info/RECORD,,
@@ -1,110 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: qdesc
3
- Version: 0.1.9
4
- Summary: Quick and Easy way to do descriptive analysis.
5
- Author: Paolo Hilado
6
- Author-email: datasciencepgh@proton.me
7
- Description-Content-Type: text/markdown
8
- License-File: LICENCE.txt
9
- Dynamic: author
10
- Dynamic: author-email
11
- Dynamic: description
12
- Dynamic: description-content-type
13
- Dynamic: license-file
14
- Dynamic: summary
15
-
16
- # qdesc - Quick and Easy Descriptive Analysis
17
-
18
- ## Overview
19
- This is a package for quick and easy descriptive analysis.
20
- Required packages include: pandas, numpy, and SciPy version 1.14.1
21
- Be sure to run the following prior to using the "qd.desc" function:
22
-
23
- - import pandas as pd
24
- - import numpy as np
25
- - from scipy.stats import anderson
26
- - import qdesc as qd
27
-
28
- The qdesc package provides a quick and easy approach to do descriptive analysis for quantitative data.
29
-
30
- ## qd.desc Function
31
- Run the function qd.desc(df) to get the following statistics:
32
- * count - number of observations
33
- * mean - measure of central tendency for normal distribution
34
- * std - measure of spread for normal distribution
35
- * median - measure of central tendency for skewed distributions or those with outliers
36
- * MAD - measure of spread for skewed distributions or those with outliers; this is manual Median Absolute Deviation (MAD) which is more robust when dealing with non-normal distributions.
37
- * min - lowest observed value
38
- * max - highest observed value
39
- * AD_stat - Anderson - Darling Statistic
40
- * 5% crit_value - critical value for a 5% Significance Level
41
- * 1% crit_value - critical value for a 1% Significance Level
42
-
43
- ## qd.freqdist Function
44
- Run the function qd.freqdist(df, "Variable Name") to easily create a frequency distribution for your chosen categorical variable with the following:
45
- * Variable Levels (i.e., for Sex Variable: Male and Female)
46
- * Counts - the number of observations
47
- * Percentage - percentage of observations from total.
48
-
49
- ## qd.freqdist_a Function
50
- Run the function qd.freqdist_a(df, ascending = FALSE) to easily create frequency distribution tables, arranged in descending manner (default) or ascending (TRUE), for all
51
- the categorical variables in your data frame. The resulting table will include columns such as:
52
- * Variable levels (i.e., for Satisfaction: Very Low, Low, Moderate, High, Very High)
53
- * Counts - the number of observations
54
- * Percentage - percentage of observations from total.
55
-
56
- ## qd.freqdist_to_excel Function
57
- Run the function qd.freqdist_to_excel(df, "Name of file.xlsx", ascending = FALSE ) to easily create frequency distribution tables, arranged in descending manner (default) or ascending (TRUE), for all the categorical variables in your data frame and SAVED as separate sheets in the .xlsx File. The resulting table will include columns such as:
58
- * Variable levels (i.e., for Satisfaction: Very Low, Low, Moderate, High, Very High)
59
- * Counts - the number of observations
60
- * Percentage - percentage of observations from total.
61
-
62
- ## qd.normcheck_dashboard Function
63
- Run the function qd.normcheck_dashboard(df) to efficiently check each numeric variable for normality of its distribution. It will compute the Anderson-Darling statistic and
64
- create visualizations (i.e., qq-plot, histogram, and boxplots) for checking whether the distribution is approximately normal.
65
-
66
-
67
- ## Installation
68
- pip install qdesc
69
-
70
- ## Sample use of qdesc functions
71
-
72
- ## Creating a sample dataframe
73
- import pandas as pd
74
- import numpy as np
75
-
76
- ## Set seed for reproducibility
77
- np.random.seed(21)
78
-
79
- ## Create two continuous variables
80
- var1 = np.random.normal(loc=0, scale=1, size=1000)
81
- var2 = np.random.uniform(low=10, high=50, size=1000)
82
-
83
- ## Create DataFrame
84
- df = pd.DataFrame({
85
- 'Normal_Variable': var1,
86
- 'Uniform_Variable': var2
87
- })
88
-
89
- ## Using the qdesc function
90
- import qdesc as qd
91
-
92
- qd.desc(df)
93
-
94
- ## License
95
- This project is licensed under the GPL-3 License. See the LICENSE file for more details.
96
-
97
- ## Acknowledgements
98
- Acknowledgement of the libraries used by this package...
99
-
100
- ### Pandas
101
- Pandas is distributed under the BSD 3-Clause License, pandas is developed by Pandas contributors. Copyright (c) 2008-2024, the pandas development team All rights reserved.
102
- ### NumPy
103
- NumPy is distributed under the BSD 3-Clause License, numpy is developed by NumPy contributors. Copyright (c) 2005-2024, NumPy Developers. All rights reserved.
104
- ### SciPy
105
- SciPy is distributed under the BSD License, scipy is developed by SciPy contributors. Copyright (c) 2001-2024, SciPy Developers. All rights reserved.
106
-
107
-
108
-
109
-
110
-
@@ -1,6 +0,0 @@
1
- qdesc/__init__.py,sha256=5EZcXkVluxvCnCmKqOty4lRmcyMJRDD0pz6wuTbnpzQ,8120
2
- qdesc-0.1.9.dist-info/licenses/LICENCE.txt,sha256=xdFo-Rt6I7EP7C_qrVeIBIcH_7mRGUh8sciJs2R8VmY,9684
3
- qdesc-0.1.9.dist-info/METADATA,sha256=iRg9Fy_IWrgvGeVFar5ATbv8eIAaso_GoY9Wr77fgKA,4543
4
- qdesc-0.1.9.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
5
- qdesc-0.1.9.dist-info/top_level.txt,sha256=JuSs1wWRGN77DVuq-SX-5P7m_mIZF0ikEVgPTBOrHb0,6
6
- qdesc-0.1.9.dist-info/RECORD,,
File without changes