Example #1
0
    def test(self):
        d1 = [
            2.0, 3.0, 5.0, 7.0, 11.0, 13.0, 17.0, 19.0, 23.0, 29.0, 31.0, 37.0,
            43.0, 47.0
        ]
        d2 = [
            2.5, 3.0, 5.0, 7.0, None, 13.0, 17.0, 19.0, 23.0, 29.0, 31.0, 37.0,
            43.0, 46.5
        ]
        t1 = pd.DataFrame({'d1': d1, 'd2': d2})
        print(t1)

        stats1 = ['sum', 'avg', 'variance', 'std', 'max', 'min', 'range']
        stats2 = ['q1', 'percentile', 'trimmed_mean']
        stats3 = [
            'max', 'min', 'range', 'sum', 'avg', 'variance', 'stddev',
            'skewness', 'kurtosis', 'nrow', 'num_of_value', 'null_count',
            'mode', 'median', 'q1', 'q3', 'iqr', 'percentile', 'trimmed_mean'
        ]
        pa_list = [0.25, 0.25]
        ta_list = [0.20, 0.20]
        out1 = statistic_summary(t1,
                                 input_cols=['d1', 'd2'],
                                 statistics=stats1)
        print(out1['out_table'])
        out2 = statistic_summary(t1,
                                 input_cols=['d1', 'd2'],
                                 statistics=stats2,
                                 percentile_amounts=pa_list,
                                 trimmed_mean_amounts=ta_list)
        print(out2['out_table'])
        out3 = statistic_summary(t1,
                                 input_cols=['d1', 'd2'],
                                 statistics=stats3,
                                 percentile_amounts=[0.25, 0.75],
                                 trimmed_mean_amounts=[0.15, 0.45])
        print(out3['out_table'])
        print(out3['out_table'].columns.values)

        d_out1 = statistic_derivation(t1,
                                      input_cols=['d1', 'd2'],
                                      statistics=stats1)
        print(d_out1['out_table'])
        print(d_out1['out_table'].columns.values)

        d_out2 = statistic_derivation(t1,
                                      input_cols=['d1', 'd2'],
                                      statistics=stats2,
                                      percentile_amounts=pa_list,
                                      trimmed_mean_amounts=ta_list)
        print(d_out2['out_table'])
        print(d_out2['out_table'].columns.values)
Example #2
0
    def test_first(self):

        sd = statistic_derivation(self.testdata,
                                  input_cols=['sepal_length'],
                                  statistics=['max'])
        DF1 = sd['out_table'].values
        # print(DF1)
        np.testing.assert_almost_equal(DF1[0][5], 7.9, 10)
        np.testing.assert_almost_equal(DF1[1][5], 7.9, 10)
        np.testing.assert_almost_equal(DF1[2][5], 7.9, 10)
        np.testing.assert_almost_equal(DF1[3][5], 7.9, 10)
        np.testing.assert_almost_equal(DF1[4][5], 7.9, 10)
Example #3
0
    def test_deriv1(self):
        d = {
            'd1': [2.0, 3.0, 5.0, 7.0, 11.0, 13.0, 17.0, 19.0],
            'd2': [2.7, 3.7, 5.7, 7.7, 11.7, 13.7, 17.7, 19.7],
            'd3': [2.7, 3.7, None, 7.7, np.nan, 13.7, 17.7, 19.7],
        }
        df = pd.DataFrame(d)

        #out = statistic_derivation(df, ['d1','d2','d3'], ['min', 'max', 'mode', 'percentile'], [0.1, 0.75], [0.1, 0.3])['out_table']
        out = statistic_derivation(df, ['d1', 'd2', 'd3'], ['min', 'mode'],
                                   [0.1, 0.75], [0.1, 0.3])['out_table']
        print(out)
Example #4
0
    def test_second(self):

        sd = statistic_derivation(
            self.testdata,
            input_cols=['petal_width'],
            statistics=['sum', 'variance', 'trimmed_mean'],
            trimmed_mean_amounts=[0.2])
        DF2 = sd['out_table'].values
        # print(DF2)
        np.testing.assert_array_almost_equal(
            DF2[0][5:8], [179.8, 0.5824143176733784, 1.2022222222222223], 10)
        np.testing.assert_array_almost_equal(
            DF2[1][5:8], [179.8, 0.5824143176733784, 1.2022222222222223], 10)
        np.testing.assert_array_almost_equal(
            DF2[2][5:8], [179.8, 0.5824143176733784, 1.2022222222222223], 10)
        np.testing.assert_array_almost_equal(
            DF2[3][5:8], [179.8, 0.5824143176733784, 1.2022222222222223], 10)
        np.testing.assert_array_almost_equal(
            DF2[4][5:8], [179.8, 0.5824143176733784, 1.2022222222222223], 10)