analysistoolbox 4.2.0__tar.gz → 4.2.2__tar.gz

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.
Files changed (154) hide show
  1. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/PKG-INFO +1 -1
  2. analysistoolbox-4.2.2/analysistoolbox/data_processing/AddIndexOfDissimilarityColumn.py +198 -0
  3. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/VerifyGranularity.py +70 -10
  4. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/__init__.py +1 -0
  5. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/SimulateStandingOvationModel.py +1 -1
  6. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox.egg-info/PKG-INFO +1 -1
  7. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox.egg-info/SOURCES.txt +1 -0
  8. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/setup.py +1 -1
  9. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/LICENSE.md +0 -0
  10. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/README.md +0 -0
  11. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/__init__.py +0 -0
  12. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/calculus/FindDerivative.py +0 -0
  13. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/calculus/FindLimitOfFunction.py +0 -0
  14. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/calculus/FindMinimumSquareLoss.py +0 -0
  15. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/calculus/PlotFunction.py +0 -0
  16. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/calculus/__init__.py +0 -0
  17. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_collection/ExtractTextFromPDF.py +0 -0
  18. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_collection/FetchPDFFromURL.py +0 -0
  19. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_collection/FetchUSShapefile.py +0 -0
  20. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_collection/FetchWebsiteText.py +0 -0
  21. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_collection/GetCompanyFilings.py +0 -0
  22. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_collection/GetGoogleSearchResults.py +0 -0
  23. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_collection/GetZipFile.py +0 -0
  24. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_collection/__init__.py +0 -0
  25. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/AddDateNumberColumns.py +0 -0
  26. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/AddLeadingZeros.py +0 -0
  27. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/AddRowCountColumn.py +0 -0
  28. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/AddTPeriodColumn.py +0 -0
  29. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/AddTukeyOutlierColumn.py +0 -0
  30. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/CleanTextColumns.py +0 -0
  31. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/ConductAnomalyDetection.py +0 -0
  32. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/ConductEntityMatching.py +0 -0
  33. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/ConvertOddsToProbability.py +0 -0
  34. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/CountMissingDataByGroup.py +0 -0
  35. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/CreateBinnedColumn.py +0 -0
  36. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/CreateDataOverview.py +0 -0
  37. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/CreateRandomSampleGroups.py +0 -0
  38. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/CreateRareCategoryColumn.py +0 -0
  39. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/CreateStratifiedRandomSampleGroups.py +0 -0
  40. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/GeocodeUSAddresses.py +0 -0
  41. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/data_processing/ImputeMissingValuesUsingNearestNeighbors.py +0 -0
  42. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/descriptive_analytics/ConductManifoldLearning.py +0 -0
  43. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/descriptive_analytics/ConductPrincipalComponentAnalysis.py +0 -0
  44. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/descriptive_analytics/ConductPropensityScoreMatching.py +0 -0
  45. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/descriptive_analytics/CreateAssociationRules.py +0 -0
  46. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/descriptive_analytics/CreateGaussianMixtureClusters.py +0 -0
  47. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/descriptive_analytics/CreateHierarchicalClusters.py +0 -0
  48. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/descriptive_analytics/CreateKMeansClusters.py +0 -0
  49. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/descriptive_analytics/GenerateEDAWithLIDA.py +0 -0
  50. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/descriptive_analytics/__init__.py +0 -0
  51. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/file_management/ConvertWordDocsToPDF.py +0 -0
  52. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/file_management/ConvertWordToHTML.py +0 -0
  53. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/file_management/CreateCopyOfPDF.py +0 -0
  54. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/file_management/CreateFileTree.py +0 -0
  55. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/file_management/ImportDataFromFolder.py +0 -0
  56. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/file_management/__init__.py +0 -0
  57. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/geospatial_analysis/CalculateHaversineDistance.py +0 -0
  58. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/geospatial_analysis/ConductClusterAnalysis.py +0 -0
  59. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/geospatial_analysis/ConductSpatialAutocorrelation.py +0 -0
  60. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/geospatial_analysis/CreateChoroplethMapFromNames.py +0 -0
  61. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/geospatial_analysis/FindNearestPointOfInterest.py +0 -0
  62. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/geospatial_analysis/__init__.py +0 -0
  63. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/hypothesis_testing/ChiSquareTestOfIndependence.py +0 -0
  64. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/hypothesis_testing/ChiSquareTestOfIndependenceFromTable.py +0 -0
  65. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/hypothesis_testing/ConductCoxProportionalHazardRegression.py +0 -0
  66. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/hypothesis_testing/ConductLinearRegressionAnalysis.py +0 -0
  67. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/hypothesis_testing/ConductLogisticRegressionAnalysis.py +0 -0
  68. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/hypothesis_testing/ConductSurvivalAnalysis.py +0 -0
  69. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/hypothesis_testing/OneSampleTTest.py +0 -0
  70. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/hypothesis_testing/OneWayANOVA.py +0 -0
  71. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/hypothesis_testing/TTestOfMeanFromStats.py +0 -0
  72. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/hypothesis_testing/TTestOfProportionFromStats.py +0 -0
  73. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/hypothesis_testing/TTestOfTwoMeansFromStats.py +0 -0
  74. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/hypothesis_testing/TwoSampleTTestOfIndependence.py +0 -0
  75. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/hypothesis_testing/TwoSampleTTestPaired.py +0 -0
  76. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/hypothesis_testing/__init__.py +0 -0
  77. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/linear_algebra/CalculateEigenvalues.py +0 -0
  78. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/linear_algebra/ConvertMatrixToRowEchelonForm.py +0 -0
  79. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/linear_algebra/ConvertSystemOfEquationsToMatrix.py +0 -0
  80. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/linear_algebra/PlotVectors.py +0 -0
  81. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/linear_algebra/SolveSystemOfEquations.py +0 -0
  82. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/linear_algebra/VisualizeMatrixAsLinearTransformation.py +0 -0
  83. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/linear_algebra/__init__.py +0 -0
  84. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/llm/SendDeepResearchQuery.py +0 -0
  85. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/llm/SendPromptToAnthropic.py +0 -0
  86. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/llm/SendPromptToChatGPT.py +0 -0
  87. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/llm/__init__.py +0 -0
  88. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/network_analysis/BuildGraphFromEdgeList.py +0 -0
  89. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/network_analysis/CalculateNodeCentralityMeasures.py +0 -0
  90. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/network_analysis/__init__.py +0 -0
  91. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/predictive_analytics/CreateARIMAModel.py +0 -0
  92. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/predictive_analytics/CreateBayesClassifier.py +0 -0
  93. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/predictive_analytics/CreateBoostedTreeModel.py +0 -0
  94. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/predictive_analytics/CreateDecisionTreeModel.py +0 -0
  95. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/predictive_analytics/CreateExponentialSmoothingModel.py +0 -0
  96. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/predictive_analytics/CreateKNearestNeighborsModel.py +0 -0
  97. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/predictive_analytics/CreateLinearRegressionModel.py +0 -0
  98. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/predictive_analytics/CreateLogisticRegressionModel.py +0 -0
  99. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/predictive_analytics/CreateNeuralNetwork_SingleOutcome.py +0 -0
  100. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/predictive_analytics/__init__.py +0 -0
  101. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/prescriptive_analytics/ConductLinearOptimization.py +0 -0
  102. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/prescriptive_analytics/CreateContentBasedRecommender.py +0 -0
  103. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/prescriptive_analytics/__init__.py +0 -0
  104. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/probability/ProbabilityOfAtLeastOne.py +0 -0
  105. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/probability/ProbabilityOfHypothesisGivenData.py +0 -0
  106. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/probability/__init__.py +0 -0
  107. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/CreateCorrelatedSIPs.py +0 -0
  108. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/CreateMetalogDistribution.py +0 -0
  109. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/CreateMetalogDistributionFromPercentiles.py +0 -0
  110. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/CreateSIPDataframe.py +0 -0
  111. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/CreateSLURPDistributionFromExponentialSmoothing.py +0 -0
  112. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/CreateSLURPDistributionFromLinearRegression.py +0 -0
  113. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/CreateSLURPDistributionFromLogisticRegression.py +0 -0
  114. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/SimulateCountOfSuccesses.py +0 -0
  115. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/SimulateCountOutcome.py +0 -0
  116. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/SimulateCountUntilFirstSuccess.py +0 -0
  117. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/SimulateNormallyDistributedOutcome.py +0 -0
  118. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/SimulateSchellingSegregation.py +0 -0
  119. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/SimulateTDistributedOutcome.py +0 -0
  120. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/SimulateTimeBetweenEvents.py +0 -0
  121. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/SimulateTimeUntilNEvents.py +0 -0
  122. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/__init__.py +0 -0
  123. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/pymetalog/__init__.py +0 -0
  124. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/pymetalog/a_vector.py +0 -0
  125. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/pymetalog/class_method.py +0 -0
  126. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/pymetalog/metalog.py +0 -0
  127. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/pymetalog/pdf_quantile_functions.py +0 -0
  128. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/simulations/pymetalog/support.py +0 -0
  129. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/statistics/CalculateConfidenceIntervalOfMean.py +0 -0
  130. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/statistics/CalculateConfidenceIntervalOfProportion.py +0 -0
  131. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/statistics/__init__.py +0 -0
  132. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/Plot100PercentStackedBarChart.py +0 -0
  133. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotBarChart.py +0 -0
  134. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotBoxWhiskerByGroup.py +0 -0
  135. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotBulletChart.py +0 -0
  136. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotCard.py +0 -0
  137. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotClusteredBarChart.py +0 -0
  138. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotContingencyHeatmap.py +0 -0
  139. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotCorrelationMatrix.py +0 -0
  140. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotDensityByGroup.py +0 -0
  141. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotDotPlot.py +0 -0
  142. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotHeatmap.py +0 -0
  143. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotOverlappingAreaChart.py +0 -0
  144. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotRiskTolerance.py +0 -0
  145. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotScatterplot.py +0 -0
  146. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotSingleVariableCountPlot.py +0 -0
  147. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotSingleVariableHistogram.py +0 -0
  148. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/PlotTimeSeries.py +0 -0
  149. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/RenderTableOne.py +0 -0
  150. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox/visualizations/__init__.py +0 -0
  151. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox.egg-info/dependency_links.txt +0 -0
  152. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox.egg-info/requires.txt +0 -0
  153. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/analysistoolbox.egg-info/top_level.txt +0 -0
  154. {analysistoolbox-4.2.0 → analysistoolbox-4.2.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: analysistoolbox
3
- Version: 4.2.0
3
+ Version: 4.2.2
4
4
  Summary: A collection tools in Python for data collection and processing, statistics, analytics, and intelligence analysis.
5
5
  Home-page: https://github.com/KyleProtho/AnalysisToolBox/tree/master/analysistoolbox
6
6
  Author: Kyle Protho
@@ -0,0 +1,198 @@
1
+ # Load packages
2
+ import numpy as np
3
+ import pandas as pd
4
+
5
+ # Declare function
6
+ def AddIndexOfDissimilarityColumn(dataframe,
7
+ group_a_count_column,
8
+ group_b_count_column,
9
+ list_of_grouping_variables=None,
10
+ index_column_name='Index of Dissimilarity',
11
+ add_contribution_column=True,
12
+ contribution_column_name='Dissimilarity Contribution'):
13
+ """
14
+ Add a column containing the Index of Dissimilarity between two population groups.
15
+
16
+ This function calculates the Index of Dissimilarity (D), the most widely used measure
17
+ of residential segregation (or, more generally, of how unevenly two groups are spread
18
+ across a set of geographic units). Each row of the DataFrame must represent a single
19
+ geographic unit — such as a country, state, county, ZIP code, census tract, or block —
20
+ and contain the count of each of the two groups living in that unit.
21
+
22
+ The index is calculated as:
23
+
24
+ D = 0.5 * sum( | a_i / A - b_i / B | )
25
+
26
+ where a_i and b_i are the counts of group A and group B in unit i, and A and B are the
27
+ total counts of each group across all units in the larger area. D ranges from 0 (both
28
+ groups are distributed identically across units — perfect evenness) to 1 (the groups
29
+ never share a unit — complete segregation).
30
+
31
+ Because D describes a *collection* of units rather than any single unit, the same value
32
+ is written to every row that belongs to the larger area. If list_of_grouping_variables
33
+ is provided (e.g., a county or metro-area column on a tract-level dataset), D is
34
+ calculated separately within each larger area, so each tract receives its own county's
35
+ index. Otherwise, D is calculated across the entire DataFrame.
36
+
37
+ Optionally, each unit's contribution to D — 0.5 * | a_i / A - b_i / B | — is also added.
38
+ The contributions sum to D within each larger area, which makes it easy to see which
39
+ units drive the overall level of segregation.
40
+
41
+ The function is particularly useful for:
42
+ * Measuring racial or ethnic residential segregation within cities or metro areas
43
+ * Comparing segregation levels across counties, metros, or countries
44
+ * Tracking changes in segregation over time (e.g., across census years)
45
+ * Assessing how evenly two populations (e.g., income groups, age groups, language
46
+ speakers) are distributed across a territory
47
+ * Identifying which neighborhoods contribute most to an area's segregation
48
+
49
+ Teaching Note
50
+ -------------
51
+ Comparing group shares one unit at a time ("this tract is 80% group A") tells you about
52
+ individual places but not about the overall pattern. The Index of Dissimilarity
53
+ summarizes the whole pattern with an intuitive interpretation: it is the share of either
54
+ group that would have to move to a different unit for the two groups to be distributed
55
+ identically. A D of 0.6 means 60% of group A (or group B) would need to relocate to
56
+ achieve evenness. By convention, values below 0.3 are considered low, 0.3 to 0.6
57
+ moderate, and above 0.6 high.
58
+
59
+ D has important limitations analysts should keep in mind. It depends heavily on the
60
+ geographic units chosen (the Modifiable Areal Unit Problem): smaller units such as
61
+ blocks typically produce higher values than larger units such as tracts, so indices
62
+ should only be compared when they are built from the same kind of unit. It is also
63
+ "aspatial" — it ignores whether units with similar compositions are next to each other,
64
+ so a checkerboard of segregated blocks and a city split cleanly in half can yield the
65
+ same D. Finally, units with very small populations add random noise that biases D
66
+ upward, so consider filtering or aggregating sparsely populated units first.
67
+
68
+ Parameters
69
+ ----------
70
+ dataframe
71
+ A pandas DataFrame where each row is a single geographic unit (e.g., a country,
72
+ state, ZIP code, census tract, or block).
73
+ group_a_count_column
74
+ Name of the column containing the count of group A in each geographic unit.
75
+ Values must be non-negative numbers.
76
+ group_b_count_column
77
+ Name of the column containing the count of group B in each geographic unit.
78
+ Values must be non-negative numbers.
79
+ list_of_grouping_variables
80
+ Optional list of column names that define larger areas (e.g., ['County'] or
81
+ ['State', 'Metro Area']) within which the index is calculated separately. If None,
82
+ the index is calculated across the entire DataFrame. Defaults to None.
83
+ index_column_name
84
+ Name for the new column containing the Index of Dissimilarity. Defaults to
85
+ 'Index of Dissimilarity'.
86
+ add_contribution_column
87
+ If True, also adds a column containing each unit's contribution to the index.
88
+ Defaults to True.
89
+ contribution_column_name
90
+ Name for the new contribution column. Only used if add_contribution_column=True.
91
+ Defaults to 'Dissimilarity Contribution'.
92
+
93
+ Returns
94
+ -------
95
+ pd.DataFrame
96
+ A copy of the input DataFrame with the Index of Dissimilarity column (and,
97
+ optionally, the contribution column) added. Units with a missing count are
98
+ excluded from the calculation and receive a missing contribution. The index is
99
+ missing for any larger area in which either group has a total count of zero.
100
+
101
+ Examples
102
+ --------
103
+ # Measure segregation across the census tracts of a single city
104
+ import pandas as pd
105
+ tracts = pd.DataFrame({
106
+ 'Tract': ['001', '002', '003', '004'],
107
+ 'Group A Population': [900, 800, 100, 200],
108
+ 'Group B Population': [100, 200, 900, 800]
109
+ })
110
+ tracts = AddIndexOfDissimilarityColumn(
111
+ tracts,
112
+ group_a_count_column='Group A Population',
113
+ group_b_count_column='Group B Population'
114
+ )
115
+ # Every row receives D = 0.7, meaning 70% of either group would need to move
116
+ # for both groups to be evenly distributed across the four tracts
117
+
118
+ # Compare segregation across counties using tract-level data
119
+ tracts = pd.DataFrame({
120
+ 'County': ['Adams', 'Adams', 'Adams', 'Baker', 'Baker', 'Baker'],
121
+ 'Tract': ['001', '002', '003', '101', '102', '103'],
122
+ 'Group A Population': [500, 450, 50, 300, 320, 280],
123
+ 'Group B Population': [50, 100, 600, 310, 290, 300]
124
+ })
125
+ tracts = AddIndexOfDissimilarityColumn(
126
+ tracts,
127
+ group_a_count_column='Group A Population',
128
+ group_b_count_column='Group B Population',
129
+ list_of_grouping_variables=['County']
130
+ )
131
+ # Adams County receives a high index; Baker County receives an index near 0
132
+
133
+ # Add only the index, with a custom column name
134
+ states = pd.DataFrame({
135
+ 'State': ['A', 'B', 'C'],
136
+ 'Under 65': [5000, 7000, 3000],
137
+ 'Over 65': [1500, 1200, 1300]
138
+ })
139
+ states = AddIndexOfDissimilarityColumn(
140
+ states,
141
+ group_a_count_column='Under 65',
142
+ group_b_count_column='Over 65',
143
+ index_column_name='Age Dissimilarity',
144
+ add_contribution_column=False
145
+ )
146
+
147
+ """
148
+
149
+ # Check that the count columns exist
150
+ for column_name in [group_a_count_column, group_b_count_column]:
151
+ if column_name not in dataframe.columns:
152
+ raise ValueError(f"Column '{column_name}' was not found in the dataframe.")
153
+
154
+ # Check that the count columns are numeric and non-negative
155
+ for column_name in [group_a_count_column, group_b_count_column]:
156
+ if not pd.api.types.is_numeric_dtype(dataframe[column_name]):
157
+ raise ValueError(f"Column '{column_name}' must contain numeric counts.")
158
+ if (dataframe[column_name] < 0).any():
159
+ raise ValueError(f"Column '{column_name}' contains negative values. Counts must be non-negative.")
160
+
161
+ # Copy the dataframe so the original is not modified
162
+ dataframe = dataframe.copy()
163
+
164
+ # Warn about units with missing counts, which are excluded from the calculation
165
+ missing_mask = dataframe[group_a_count_column].isna() | dataframe[group_b_count_column].isna()
166
+ if missing_mask.any():
167
+ print(f"Warning: {missing_mask.sum()} geographic unit(s) have a missing count and will be excluded from the calculation.")
168
+ group_a_counts = dataframe[group_a_count_column].where(~missing_mask)
169
+ group_b_counts = dataframe[group_b_count_column].where(~missing_mask)
170
+
171
+ # Calculate the total of each group within each larger area (or across the whole dataframe)
172
+ if list_of_grouping_variables is None:
173
+ group_a_totals = pd.Series(group_a_counts.sum(), index=dataframe.index)
174
+ group_b_totals = pd.Series(group_b_counts.sum(), index=dataframe.index)
175
+ else:
176
+ grouping_keys = [dataframe[column_name] for column_name in list_of_grouping_variables]
177
+ group_a_totals = group_a_counts.groupby(grouping_keys, dropna=False).transform('sum')
178
+ group_b_totals = group_b_counts.groupby(grouping_keys, dropna=False).transform('sum')
179
+
180
+ # Calculate each unit's contribution to the index; areas where either group is absent are undefined
181
+ group_a_totals = group_a_totals.replace(0, np.nan)
182
+ group_b_totals = group_b_totals.replace(0, np.nan)
183
+ contributions = 0.5 * (group_a_counts / group_a_totals - group_b_counts / group_b_totals).abs()
184
+
185
+ # Sum the contributions to get the index for each larger area
186
+ if list_of_grouping_variables is None:
187
+ index_values = pd.Series(contributions.sum(min_count=1), index=dataframe.index)
188
+ else:
189
+ index_values = contributions.groupby(grouping_keys, dropna=False).transform(lambda x: x.sum(min_count=1))
190
+ index_values = index_values.where(group_a_totals.notna() & group_b_totals.notna())
191
+
192
+ # Add the new columns to the dataframe
193
+ dataframe[index_column_name] = index_values
194
+ if add_contribution_column:
195
+ dataframe[contribution_column_name] = contributions
196
+
197
+ # Return the updated dataframe
198
+ return dataframe
@@ -24,8 +24,25 @@ def VerifyGranularity(dataframe,
24
24
  * Preparing DataFrames for indexing in specialized time-series or panel data
25
25
  * Debugging ETL pipelines where row duplication may have occurred
26
26
 
27
+ Teaching Note
28
+ -------------
29
+ Granularity (or "grain") is the answer to the question "what does one row
30
+ represent?" — one customer, one order, one customer per day, and so on. Almost
31
+ every downstream calculation silently assumes a grain. If you believe a table is
32
+ one row per customer but some customers appear twice, sums double-count, averages
33
+ are weighted toward the duplicates, and joins "fan out," multiplying rows in the
34
+ result without raising any error. Because these mistakes produce plausible-looking
35
+ numbers, they are among the most common and hardest-to-spot errors in analysis.
36
+ Verifying the grain up front turns an implicit assumption into a tested fact, and
37
+ inspecting the most duplicated keys usually reveals why the assumption failed: a
38
+ missing key column (e.g., a date or version field), true duplicate records, or a
39
+ prior join that multiplied rows.
40
+
27
41
  The function provides visual feedback (check marks or warnings) and can
28
42
  optionally transform the composite key into the DataFrame's primary index.
43
+ When the key columns do not uniquely identify each row, it also shows the
44
+ 5 key combinations with the highest record counts, followed by the original
45
+ records for the most duplicated combination(s) (all ties are included).
29
46
 
30
47
  Parameters
31
48
  ----------
@@ -46,9 +63,9 @@ def VerifyGranularity(dataframe,
46
63
  Returns
47
64
  -------
48
65
  pd.DataFrame
49
- If `set_key_as_index` is True, returns the modified DataFrame with the
50
- composite key as its index. Otherwise, returns the updated DataFrame
51
- (though the original may be modified in-place).
66
+ A copy of the input DataFrame. If `set_key_as_index` is True, the
67
+ composite key is set as its index; otherwise the original index is kept.
68
+ The input DataFrame is never modified.
52
69
 
53
70
  Examples
54
71
  --------
@@ -73,9 +90,13 @@ def VerifyGranularity(dataframe,
73
90
  })
74
91
  VerifyGranularity(customers, ['Email'], print_as_markdown=False)
75
92
  # Prints a warning: counts will not match due to the duplicate Email.
93
+ # Also prints the duplicate counts by Email and the two 'test@abc.com' records.
76
94
 
77
95
  """
78
96
 
97
+ # Work on a copy so the caller's DataFrame is not modified
98
+ dataframe = dataframe.copy()
99
+
79
100
  # Create key column from list of key columns
80
101
  first_col = list_of_key_columns[0]
81
102
  dataframe['Dataset Key'] = dataframe[first_col].astype(str)
@@ -110,12 +131,51 @@ def VerifyGranularity(dataframe,
110
131
  print("WARNING: Unique combination of columns you listed does not equal number of rows in dataset. Try a new combination of columns or see if dataset has duplicates.")
111
132
  else:
112
133
  print("SUCCESS: Dataset granularity is verified using the columns you listed.")
113
-
114
- # If Key column not being kept, drop it. Otherwise, move Key column to front of DataFrame
115
- if set_key_as_index != True:
116
- dataframe = dataframe.drop(columns=['Dataset Key'])
117
- else:
134
+
135
+ # If granularity is not verified, show the most duplicated keys and their records
136
+ if row_count != distinct_key_count:
137
+ # Count records per key and keep the 5 keys with the highest duplicate counts
138
+ key_counts = dataframe['Dataset Key'].value_counts()
139
+ top_duplicate_counts = key_counts[key_counts > 1].head(5)
140
+
141
+ # Build a table of the key column values alongside their record counts
142
+ duplicate_summary = (
143
+ dataframe
144
+ .drop_duplicates(subset=['Dataset Key'])
145
+ .set_index('Dataset Key')
146
+ .loc[top_duplicate_counts.index, list_of_key_columns]
147
+ .reset_index(drop=True)
148
+ )
149
+ duplicate_summary['Record Count'] = top_duplicate_counts.values
150
+
151
+ # Get the records from the original dataset for the top duplicated key(s), including ties
152
+ max_count = top_duplicate_counts.max()
153
+ top_keys = top_duplicate_counts[top_duplicate_counts == max_count].index
154
+ top_duplicate_records = (
155
+ dataframe[dataframe['Dataset Key'].isin(top_keys)]
156
+ .sort_values('Dataset Key', kind='stable')
157
+ .drop(columns=['Dataset Key'])
158
+ )
159
+
160
+ # Show the duplicate summary and records
161
+ duplicate_summary_string = "Top " + str(len(top_duplicate_counts)) + " duplicated combinations of " + ", ".join(str(col) for col in list_of_key_columns) + ":"
162
+ top_records_string = "Records with the most duplicated combination(s) (" + "{:,}".format(max_count) + " records each):"
163
+ if print_as_markdown:
164
+ display(Markdown("**" + duplicate_summary_string + "**"))
165
+ display(duplicate_summary)
166
+ display(Markdown("**" + top_records_string + "**"))
167
+ display(top_duplicate_records)
168
+ else:
169
+ print("\n" + duplicate_summary_string)
170
+ print(duplicate_summary.to_string(index=False))
171
+ print("\n" + top_records_string)
172
+ print(top_duplicate_records.to_string())
173
+
174
+ # Set the key as the index if requested, then drop the temporary key column
175
+ if set_key_as_index:
118
176
  dataframe.index = dataframe['Dataset Key']
119
- dataframe = dataframe.drop(columns=['Dataset Key'])
120
- return(dataframe)
177
+ dataframe = dataframe.drop(columns=['Dataset Key'])
178
+
179
+ # Return the DataFrame
180
+ return dataframe
121
181
 
@@ -1,4 +1,5 @@
1
1
  from .AddDateNumberColumns import AddDateNumberColumns
2
+ from .AddIndexOfDissimilarityColumn import AddIndexOfDissimilarityColumn
2
3
  from .AddLeadingZeros import AddLeadingZeros
3
4
  from .AddRowCountColumn import AddRowCountColumn
4
5
  from .AddTPeriodColumn import AddTPeriodColumn
@@ -95,7 +95,7 @@ def SimulateStandingOvationModel(qualities=(0.4, 0.5, 0.6, 0.7),
95
95
  Whether a standing agent (other than a pioneer) sits down again when more than
96
96
  their peer threshold of the people they see are seated. Defaults to False.
97
97
  hall_shape : tuple of int, optional
98
- The shape of the hall as (rows, seats per row). Row 0 is the front. Defaults to (20, 30).
98
+ The shape of the hall as (rows, seats per row). Row 0 is the front. Defaults to (20, 40).
99
99
  neighborhood : str, optional
100
100
  Which seats an agent can see:
101
101
  * 'cone': the cone_depth rows ahead, widening by one seat on each side per
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: analysistoolbox
3
- Version: 4.2.0
3
+ Version: 4.2.2
4
4
  Summary: A collection tools in Python for data collection and processing, statistics, analytics, and intelligence analysis.
5
5
  Home-page: https://github.com/KyleProtho/AnalysisToolBox/tree/master/analysistoolbox
6
6
  Author: Kyle Protho
@@ -21,6 +21,7 @@ analysistoolbox/data_collection/GetGoogleSearchResults.py
21
21
  analysistoolbox/data_collection/GetZipFile.py
22
22
  analysistoolbox/data_collection/__init__.py
23
23
  analysistoolbox/data_processing/AddDateNumberColumns.py
24
+ analysistoolbox/data_processing/AddIndexOfDissimilarityColumn.py
24
25
  analysistoolbox/data_processing/AddLeadingZeros.py
25
26
  analysistoolbox/data_processing/AddRowCountColumn.py
26
27
  analysistoolbox/data_processing/AddTPeriodColumn.py
@@ -12,7 +12,7 @@ setup(
12
12
  long_description=long_description,
13
13
  long_description_content_type='text/markdown',
14
14
  url="https://github.com/KyleProtho/AnalysisToolBox/tree/master/analysistoolbox",
15
- version='4.2.0',
15
+ version='4.2.2',
16
16
  author='Kyle Protho',
17
17
  author_email='kyletprotho@gmail.com',
18
18
  license='GPL-3.0-or-later',