qdesc 0.1.8.5__py3-none-any.whl → 0.1.9.1__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,24 +22,61 @@ 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)
41
39
  return x_df
42
40
 
41
+
42
+ def grp_desc(df, numeric_col, group_col):
43
+ import pandas as pd
44
+ import numpy as np
45
+ from scipy.stats import median_abs_deviation, anderson
46
+ results = []
47
+ for group, group_df in df.groupby(group_col):
48
+ data = group_df[numeric_col].dropna()
49
+ if len(data) < 2:
50
+ # Not enough data for stats like std or AD test
51
+ stats = {
52
+ group_col: group,
53
+ 'count': len(data),
54
+ 'mean': np.nan,
55
+ 'std': np.nan,
56
+ 'median': np.nan,
57
+ 'mad': np.nan,
58
+ 'min': np.nan,
59
+ 'max': np.nan,
60
+ 'anderson_stat': np.nan,
61
+ 'crit_5%': np.nan
62
+ }
63
+ else:
64
+ ad_result = anderson(data, dist='norm')
65
+ stats = {
66
+ group_col: group,
67
+ 'count': len(data),
68
+ 'mean': data.mean(),
69
+ 'std': data.std(),
70
+ 'median': data.median(),
71
+ 'mad': median_abs_deviation(data),
72
+ 'min': data.min(),
73
+ 'max': data.max(),
74
+ 'AD_stat': ad_result.statistic,
75
+ 'crit_5%': ad_result.critical_values[2], # 5% is the third value
76
+ }
77
+ results.append(stats)
78
+ return np.round(pd.DataFrame(results),2)
79
+
43
80
  def freqdist(df, column_name):
44
81
  import pandas as pd
45
82
  if column_name not in df.columns:
@@ -1,11 +1,17 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: qdesc
3
- Version: 0.1.8.5
3
+ Version: 0.1.9.1
4
4
  Summary: Quick and Easy way to do descriptive analysis.
5
5
  Author: Paolo Hilado
6
6
  Author-email: datasciencepgh@proton.me
7
7
  Description-Content-Type: text/markdown
8
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
9
15
 
10
16
  # qdesc - Quick and Easy Descriptive Analysis
11
17
 
@@ -0,0 +1,6 @@
1
+ qdesc/__init__.py,sha256=-NWrytwAkpgU387wvyk5ORWMNEERuRKQlWzWM_DBZi8,7861
2
+ qdesc-0.1.9.1.dist-info/licenses/LICENCE.txt,sha256=xdFo-Rt6I7EP7C_qrVeIBIcH_7mRGUh8sciJs2R8VmY,9684
3
+ qdesc-0.1.9.1.dist-info/METADATA,sha256=A_XkoWOTN_s9ZJtO8Bvm586OEKESqiGTLNgxNzHMIXY,4545
4
+ qdesc-0.1.9.1.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
5
+ qdesc-0.1.9.1.dist-info/top_level.txt,sha256=JuSs1wWRGN77DVuq-SX-5P7m_mIZF0ikEVgPTBOrHb0,6
6
+ qdesc-0.1.9.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: setuptools (80.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,6 +0,0 @@
1
- qdesc/__init__.py,sha256=1I8XCqG4wwqfKijIVFRZ-PK84MiKOkW57zWU372NPRc,6624
2
- qdesc-0.1.8.5.dist-info/LICENCE.txt,sha256=xdFo-Rt6I7EP7C_qrVeIBIcH_7mRGUh8sciJs2R8VmY,9684
3
- qdesc-0.1.8.5.dist-info/METADATA,sha256=qhonWRLjCIoRy2s2T58oepk02dsdC0t2ZwP2nliifP0,4407
4
- qdesc-0.1.8.5.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
5
- qdesc-0.1.8.5.dist-info/top_level.txt,sha256=JuSs1wWRGN77DVuq-SX-5P7m_mIZF0ikEVgPTBOrHb0,6
6
- qdesc-0.1.8.5.dist-info/RECORD,,