Luis
Luis

Reputation: 1584

How to apply a function by group?

I'm coming from another topic in which this discussion started. Let's say I have this pandas data frame from psychological research, in which I have a factor variable (country), and some items from a Likert scale.

import pandas as pd
import numpy as np
import pingouin as pg
from numpy import nan

sim_data = pd.DataFrame.from_dict({'country': {33003: 'Vietnam',
  12172: 'Macedonia',
  5192: 'Ghana',
  32511: 'Vietnam',
  7813: 'Ghana',
  21440: 'Armenia',
  32912: 'Vietnam',
  20609: 'Georgia',
  7751: 'Ghana',
  31228: 'Laos',
  36230: 'Serbia',
  32025: 'Laos',
  21758: 'Armenia',
  35730: 'Serbia',
  8444: 'Kenya',
  19946: 'Georgia',
  37532: 'Serbia',
  22926: 'Armenia',
  27204: 'Sri_Lanka',
  31959: 'Laos',
  24535: 'Sri_Lanka',
  19433: 'Georgia',
  17137: 'Ukraine',
  26103: 'Sri_Lanka',
  33878: 'Vietnam',
  39053: 'Philippines',
  33799: 'Vietnam',
  37183: 'Serbia',
  3606: 'Colombia',
  2561: 'Colombia',
  29960: 'Laos',
  32397: 'Vietnam',
  39539: 'Philippines',
  431: 'Bolivia',
  36842: 'Serbia',
  16926: 'Ukraine',
  9287: 'Kenya',
  34246: 'Vietnam',
  16277: 'Ukraine',
  34105: 'Vietnam',
  11032: 'Kenya',
  41457: 'Philippines',
  34380: 'Vietnam',
  19482: 'Georgia',
  1844: 'Bolivia',
  9552: 'Kenya',
  35437: 'Vietnam',
  29555: 'Laos',
  29993: 'Laos',
  28114: 'Yunnan',
  15: 'Bolivia',
  27712: 'Yunnan',
  12313: 'Macedonia',
  11631: 'Kenya'},
 'step_bfi1_ab_cor': {33003: 1.8333332538604736,
  12172: 1.5,
  5192: nan,
  32511: 1.4166666269302368,
  7813: nan,
  21440: 2.4166665077209473,
  32912: 1.0,
  20609: 4.0,
  7751: 0.5,
  31228: 2.25,
  36230: 2.9375,
  32025: 1.875,
  21758: 3.9166665077209473,
  35730: 2.25,
  8444: 3.5833334922790527,
  19946: 2.3333334922790527,
  37532: 4.0625,
  22926: 3.5,
  27204: 4.083333492279053,
  31959: 3.0,
  24535: 3.5,
  19433: 2.0833334922790527,
  17137: 3.25,
  26103: 1.1666666269302368,
  33878: 1.6666667461395264,
  39053: 1.75,
  33799: 0.75,
  37183: 3.375,
  3606: 4.25,
  2561: 2.8333334922790527,
  29960: 4.25,
  32397: 3.8333332538604736,
  39539: 2.5625,
  431: 3.25,
  36842: 3.8125,
  16926: 1.9166667461395264,
  9287: 2.3333334922790527,
  34246: 1.0,
  16277: 2.9166667461395264,
  34105: 1.5833333730697632,
  11032: 1.75,
  41457: 3.75,
  34380: 1.5833332538604736,
  19482: 0.9166666269302368,
  1844: 3.6666667461395264,
  9552: 2.25,
  35437: 1.0833332538604736,
  29555: 2.25,
  29993: 4.25,
  28114: 3.6666665077209473,
  15: 3.0,
  27712: 3.25,
  12313: 2.0833334922790527,
  11631: 2.5833334922790527},
 'step_bfi3_ab_cor': {33003: 3.8333332538604736,
  12172: 3.5,
  5192: nan,
  32511: 3.4166665077209473,
  7813: nan,
  21440: 3.4166665077209473,
  32912: 3.0,
  20609: 4.0,
  7751: 2.5,
  31228: 4.25,
  36230: 3.6875,
  32025: 3.875,
  21758: 3.9166665077209473,
  35730: 2.25,
  8444: 4.583333492279053,
  19946: 2.3333334922790527,
  37532: 2.5625,
  22926: 2.5,
  27204: 3.0833334922790527,
  31959: 4.0,
  24535: 2.5,
  19433: 3.0833334922790527,
  17137: 3.25,
  26103: 3.1666665077209473,
  33878: 3.6666667461395264,
  39053: 2.5,
  33799: 3.75,
  37183: 3.375,
  3606: 4.25,
  2561: 2.8333334922790527,
  29960: 3.25,
  32397: 2.8333332538604736,
  39539: 2.5625,
  431: 3.25,
  36842: 3.0625,
  16926: 3.9166667461395264,
  9287: 3.3333334922790527,
  34246: 4.0,
  16277: 1.9166667461395264,
  34105: 3.5833334922790527,
  11032: 3.75,
  41457: 2.25,
  34380: 2.5833332538604736,
  19482: 3.9166665077209473,
  1844: 2.6666667461395264,
  9552: 3.25,
  35437: 3.0833332538604736,
  29555: 2.25,
  29993: 2.25,
  28114: 3.6666665077209473,
  15: 3.0,
  27712: 2.25,
  12313: 4.083333492279053,
  11631: 3.5833334922790527},
 'step_bfi5_ab_cor': {33003: 0.8333332538604736,
  12172: 0.5,
  5192: nan,
  32511: 2.4166665077209473,
  7813: nan,
  21440: 2.4166665077209473,
  32912: 2.0,
  20609: 2.0,
  7751: 0.5,
  31228: 3.25,
  36230: 3.6875,
  32025: 1.875,
  21758: 3.9166665077209473,
  35730: 2.25,
  8444: 1.5833333730697632,
  19946: 1.3333333730697632,
  37532: 1.8125,
  22926: 1.5,
  27204: 2.0833334922790527,
  31959: 3.0,
  24535: 1.5,
  19433: 1.0833333730697632,
  17137: 2.25,
  26103: 4.166666507720947,
  33878: 1.6666667461395264,
  39053: 1.75,
  33799: 1.75,
  37183: 3.375,
  3606: 2.25,
  2561: 1.8333333730697632,
  29960: 3.25,
  32397: 1.8333332538604736,
  39539: 2.5625,
  431: 1.25,
  36842: 3.8125,
  16926: 1.9166667461395264,
  9287: 1.3333333730697632,
  34246: 3.0,
  16277: 1.9166667461395264,
  34105: 1.5833333730697632,
  11032: 2.75,
  41457: 2.25,
  34380: 2.5833332538604736,
  19482: 1.9166666269302368,
  1844: 3.6666667461395264,
  9552: 1.25,
  35437: 1.0833332538604736,
  29555: 1.25,
  29993: 3.25,
  28114: 2.6666665077209473,
  15: 2.0,
  27712: 3.25,
  12313: 1.0833333730697632,
  11631: 3.5833334922790527},
 'step_bfi6_ab_cor': {33003: 4.1666669845581055,
  12172: 1.5,
  5192: nan,
  32511: 1.5833333730697632,
  7813: nan,
  21440: 2.5833334922790527,
  32912: 4.0,
  20609: 3.0,
  7751: 1.5,
  31228: 2.75,
  36230: 2.8125,
  32025: 4.125,
  21758: 4.083333492279053,
  35730: 1.25,
  8444: 3.4166665077209473,
  19946: 2.6666665077209473,
  37532: 3.9375,
  22926: 2.5,
  27204: 2.9166665077209473,
  31959: 2.0,
  24535: 2.5,
  19433: 2.9166665077209473,
  17137: 2.75,
  26103: 0.8333333730697632,
  33878: 4.3333330154418945,
  39053: 2.5,
  33799: 4.25,
  37183: 3.125,
  3606: 2.75,
  2561: 3.1666665077209473,
  29960: 3.75,
  32397: 1.1666667461395264,
  39539: 3.9375,
  431: 1.75,
  36842: 2.6875,
  16926: 2.0833332538604736,
  9287: 2.6666665077209473,
  34246: 3.0,
  16277: 2.0833332538604736,
  34105: 2.4166665077209473,
  11032: 3.25,
  41457: 4.25,
  34380: 2.4166667461395264,
  19482: 4.083333492279053,
  1844: 3.3333332538604736,
  9552: 2.75,
  35437: 2.9166667461395264,
  29555: 1.75,
  29993: 2.75,
  28114: 3.3333334922790527,
  15: 2.0,
  27712: 1.75,
  12313: 2.9166665077209473,
  11631: 3.4166665077209473},
 'step_bfi7_ab_cor': {33003: 1.8333332538604736,
  12172: 1.5,
  5192: nan,
  32511: 1.4166666269302368,
  7813: nan,
  21440: 2.4166665077209473,
  32912: 3.0,
  20609: 2.0,
  7751: 1.5,
  31228: 3.25,
  36230: 3.6875,
  32025: 1.875,
  21758: 3.9166665077209473,
  35730: 3.75,
  8444: 2.5833334922790527,
  19946: 1.3333333730697632,
  37532: 4.0625,
  22926: 2.5,
  27204: 3.0833334922790527,
  31959: 1.0,
  24535: 1.5,
  19433: 2.0833334922790527,
  17137: 2.25,
  26103: 2.1666665077209473,
  33878: 2.6666667461395264,
  39053: 3.25,
  33799: 0.75,
  37183: 3.375,
  3606: 2.25,
  2561: 1.8333333730697632,
  29960: 2.25,
  32397: 3.8333332538604736,
  39539: 4.0625,
  431: 3.25,
  36842: 3.8125,
  16926: 1.9166667461395264,
  9287: 2.3333334922790527,
  34246: 2.0,
  16277: 2.9166667461395264,
  34105: 1.5833333730697632,
  11032: 1.75,
  41457: 3.75,
  34380: 2.5833332538604736,
  19482: 2.9166665077209473,
  1844: 1.6666667461395264,
  9552: 2.25,
  35437: 2.0833332538604736,
  29555: 2.25,
  29993: 2.25,
  28114: 3.6666665077209473,
  15: 3.0,
  27712: 1.25,
  12313: 4.083333492279053,
  11631: 3.5833334922790527},
 'step_bfi10_ab_cor': {33003: 3.8333332538604736,
  12172: 3.5,
  5192: nan,
  32511: 3.4166665077209473,
  7813: nan,
  21440: 3.4166665077209473,
  32912: 3.0,
  20609: 4.0,
  7751: 3.5,
  31228: 3.25,
  36230: 3.6875,
  32025: 1.875,
  21758: 3.9166665077209473,
  35730: 2.25,
  8444: 2.5833334922790527,
  19946: 4.333333492279053,
  37532: 2.5625,
  22926: 2.5,
  27204: 4.083333492279053,
  31959: 2.0,
  24535: 0.4999999403953552,
  19433: 3.0833334922790527,
  17137: 3.25,
  26103: 3.1666665077209473,
  33878: 2.6666667461395264,
  39053: 3.25,
  33799: 1.75,
  37183: 3.375,
  3606: 2.25,
  2561: 2.8333334922790527,
  29960: 2.25,
  32397: 1.8333332538604736,
  39539: 4.0625,
  431: 3.25,
  36842: 3.0625,
  16926: 3.9166667461395264,
  9287: 2.3333334922790527,
  34246: 4.0,
  16277: 2.9166667461395264,
  34105: 2.5833334922790527,
  11032: 3.75,
  41457: 2.25,
  34380: 3.5833332538604736,
  19482: 3.9166665077209473,
  1844: 3.6666667461395264,
  9552: 3.25,
  35437: 3.0833332538604736,
  29555: 2.25,
  29993: 2.25,
  28114: 3.6666665077209473,
  15: 3.0,
  27712: 3.25,
  12313: 2.0833334922790527,
  11631: 4.583333492279053},
 'step_bfi17_ab_cor': {33003: 2.8333332538604736,
  12172: 1.5,
  5192: nan,
  32511: 3.4166665077209473,
  7813: nan,
  21440: 1.4166666269302368,
  32912: 2.0,
  20609: 1.0,
  7751: 3.5,
  31228: 3.25,
  36230: 2.1875,
  32025: nan,
  21758: 3.9166665077209473,
  35730: 3.75,
  8444: 3.5833334922790527,
  19946: 2.3333334922790527,
  37532: 2.5625,
  22926: 2.5,
  27204: 3.0833334922790527,
  31959: 3.0,
  24535: 2.5,
  19433: 4.083333492279053,
  17137: 2.25,
  26103: 2.1666665077209473,
  33878: 2.6666667461395264,
  39053: 1.75,
  33799: 2.75,
  37183: 3.375,
  3606: 4.25,
  2561: 0.8333333730697632,
  29960: 3.25,
  32397: 1.8333332538604736,
  39539: 2.5625,
  431: 1.25,
  36842: 2.3125,
  16926: 2.9166667461395264,
  9287: 3.3333334922790527,
  34246: 2.0,
  16277: 2.9166667461395264,
  34105: 3.5833334922790527,
  11032: 2.75,
  41457: 3.75,
  34380: 2.5833332538604736,
  19482: 3.9166665077209473,
  1844: 3.6666667461395264,
  9552: 3.25,
  35437: 2.0833332538604736,
  29555: 2.25,
  29993: 2.25,
  28114: 3.6666665077209473,
  15: 3.0,
  27712: 2.25,
  12313: 3.0833334922790527,
  11631: 3.5833334922790527},
 'step_bfi19_ab_cor': {33003: 3.1666667461395264,
  12172: 1.5,
  5192: nan,
  32511: 1.5833333730697632,
  7813: nan,
  21440: 2.5833334922790527,
  32912: 2.0,
  20609: 1.0,
  7751: 1.5,
  31228: 2.75,
  36230: 2.0625,
  32025: 2.125,
  21758: 1.0833333730697632,
  35730: 4.25,
  8444: 3.4166665077209473,
  19946: 3.6666665077209473,
  37532: 0.9375,
  22926: 2.5,
  27204: 2.9166665077209473,
  31959: 3.0,
  24535: 1.5,
  19433: 2.9166665077209473,
  17137: 2.75,
  26103: 1.8333333730697632,
  33878: 3.3333332538604736,
  39053: 3.25,
  33799: 3.25,
  37183: 3.125,
  3606: 2.75,
  2561: 3.1666665077209473,
  29960: 1.75,
  32397: 3.1666667461395264,
  39539: 2.4375,
  431: 1.75,
  36842: 2.6875,
  16926: 3.0833332538604736,
  9287: 4.666666507720947,
  34246: 3.0,
  16277: 2.0833332538604736,
  34105: 3.4166665077209473,
  11032: 3.25,
  41457: 2.75,
  34380: 2.4166667461395264,
  19482: 3.0833334922790527,
  1844: 4.3333330154418945,
  9552: 2.75,
  35437: 2.9166667461395264,
  29555: 1.75,
  29993: 1.75,
  28114: 3.3333334922790527,
  15: 2.0,
  27712: 2.75,
  12313: 0.9166666269302368,
  11631: 2.4166665077209473},
 'step_bfi23_ab_cor': {33003: 1.1666667461395264,
  12172: 3.5,
  5192: nan,
  32511: 4.583333492279053,
  7813: nan,
  21440: 3.5833334922790527,
  32912: 2.0,
  20609: 4.0,
  7751: 4.5,
  31228: 2.75,
  36230: 3.5625,
  32025: nan,
  21758: 4.083333492279053,
  35730: 4.25,
  8444: 3.4166665077209473,
  19946: 3.6666665077209473,
  37532: 3.9375,
  22926: 3.5,
  27204: 2.9166665077209473,
  31959: 3.0,
  24535: 2.5,
  19433: 2.9166665077209473,
  17137: 2.75,
  26103: 3.8333334922790527,
  33878: 1.3333332538604736,
  39053: 1.75,
  33799: 2.25,
  37183: 4.625,
  3606: 2.75,
  2561: 3.1666665077209473,
  29960: 2.75,
  32397: 3.1666667461395264,
  39539: 2.4375,
  431: 3.75,
  36842: 3.4375,
  16926: 3.0833332538604736,
  9287: 1.6666666269302368,
  34246: 3.0,
  16277: 3.0833332538604736,
  34105: 1.4166666269302368,
  11032: 4.25,
  41457: 2.75,
  34380: 2.4166667461395264,
  19482: 4.083333492279053,
  1844: 3.3333332538604736,
  9552: 3.75,
  35437: 1.9166667461395264,
  29555: 2.75,
  29993: 2.75,
  28114: 3.3333334922790527,
  15: 4.0,
  27712: 2.75,
  12313: 2.9166665077209473,
  11631: 3.4166665077209473},
 'step_bfi30_ab_cor': {33003: 1.8333332538604736,
  12172: 3.5,
  5192: nan,
  32511: 2.4166665077209473,
  7813: nan,
  21440: 3.4166665077209473,
  32912: 4.0,
  20609: 4.0,
  7751: 3.5,
  31228: 3.25,
  36230: 3.6875,
  32025: 1.875,
  21758: 3.9166665077209473,
  35730: 2.25,
  8444: 2.5833334922790527,
  19946: 4.333333492279053,
  37532: 4.0625,
  22926: 3.5,
  27204: 4.083333492279053,
  31959: 4.0,
  24535: 3.5,
  19433: 4.083333492279053,
  17137: 3.25,
  26103: 3.1666665077209473,
  33878: 3.6666667461395264,
  39053: 1.0,
  33799: 0.75,
  37183: 3.375,
  3606: 4.25,
  2561: 2.8333334922790527,
  29960: 3.25,
  32397: 2.8333332538604736,
  39539: 4.0625,
  431: 3.25,
  36842: 3.8125,
  16926: 2.9166667461395264,
  9287: 2.3333334922790527,
  34246: 3.0,
  16277: 2.9166667461395264,
  34105: 2.5833334922790527,
  11032: 3.75,
  41457: 3.75,
  34380: 3.5833332538604736,
  19482: 3.9166665077209473,
  1844: 3.6666667461395264,
  9552: 2.25,
  35437: 3.0833332538604736,
  29555: 2.25,
  29993: 3.25,
  28114: 3.6666665077209473,
  15: 1.0,
  27712: 3.25,
  12313: 4.083333492279053,
  11631: 4.583333492279053},
 'step_bfi32_ab_cor': {33003: 3.8333332538604736,
  12172: 1.5,
  5192: nan,
  32511: 3.4166665077209473,
  7813: nan,
  21440: 3.4166665077209473,
  32912: 4.0,
  20609: 4.0,
  7751: 3.5,
  31228: 3.25,
  36230: 2.9375,
  32025: 2.875,
  21758: 3.9166665077209473,
  35730: 2.25,
  8444: 3.5833334922790527,
  19946: 4.333333492279053,
  37532: 3.3125,
  22926: 3.5,
  27204: 4.083333492279053,
  31959: 3.0,
  24535: 2.5,
  19433: 4.083333492279053,
  17137: 3.25,
  26103: 3.1666665077209473,
  33878: 3.6666667461395264,
  39053: 1.75,
  33799: 3.75,
  37183: 1.875,
  3606: 4.25,
  2561: 2.8333334922790527,
  29960: 3.25,
  32397: 2.8333332538604736,
  39539: 2.5625,
  431: 3.25,
  36842: 3.0625,
  16926: 2.9166667461395264,
  9287: 2.3333334922790527,
  34246: 4.0,
  16277: 2.9166667461395264,
  34105: 3.5833334922790527,
  11032: 3.75,
  41457: 2.25,
  34380: 2.5833332538604736,
  19482: 3.9166665077209473,
  1844: 3.6666667461395264,
  9552: 3.25,
  35437: 3.0833332538604736,
  29555: 3.25,
  29993: 3.25,
  28114: 3.6666665077209473,
  15: 3.0,
  27712: 2.25,
  12313: 3.0833334922790527,
  11631: 3.5833334922790527},
 'step_bfi33_ab_cor': {33003: 1.8333332538604736,
  12172: 3.5,
  5192: nan,
  32511: 3.4166665077209473,
  7813: nan,
  21440: 2.4166665077209473,
  32912: 4.0,
  20609: 2.0,
  7751: 3.5,
  31228: 3.25,
  36230: 2.9375,
  32025: 3.875,
  21758: 3.9166665077209473,
  35730: 3.75,
  8444: 3.5833334922790527,
  19946: 4.333333492279053,
  37532: 4.0625,
  22926: 2.5,
  27204: 3.0833334922790527,
  31959: 2.0,
  24535: 1.5,
  19433: 2.0833334922790527,
  17137: 1.25,
  26103: 3.1666665077209473,
  33878: 3.6666667461395264,
  39053: 2.5,
  33799: 3.75,
  37183: 3.375,
  3606: 2.25,
  2561: 2.8333334922790527,
  29960: 3.25,
  32397: 2.8333332538604736,
  39539: 3.3125,
  431: 2.25,
  36842: 3.0625,
  16926: 2.9166667461395264,
  9287: 3.3333334922790527,
  34246: 3.0,
  16277: 2.9166667461395264,
  34105: 3.5833334922790527,
  11032: 3.75,
  41457: 3.75,
  34380: 3.5833332538604736,
  19482: 3.9166665077209473,
  1844: 3.6666667461395264,
  9552: 2.25,
  35437: 3.0833332538604736,
  29555: 3.25,
  29993: 2.25,
  28114: 3.6666665077209473,
  15: 3.0,
  27712: 1.25,
  12313: 3.0833334922790527,
  11631: 3.5833334922790527},
 'step_bfi34_ab_cor': {33003: 3.8333332538604736,
  12172: 1.5,
  5192: nan,
  32511: 3.4166665077209473,
  7813: nan,
  21440: 3.4166665077209473,
  32912: 3.0,
  20609: 1.0,
  7751: 3.5,
  31228: 2.25,
  36230: 2.9375,
  32025: nan,
  21758: 3.9166665077209473,
  35730: 3.75,
  8444: 2.5833334922790527,
  19946: 3.3333334922790527,
  37532: 2.5625,
  22926: 2.5,
  27204: 2.0833334922790527,
  31959: 2.0,
  24535: 1.5,
  19433: 3.0833334922790527,
  17137: 3.25,
  26103: 2.1666665077209473,
  33878: 2.6666667461395264,
  39053: 2.5,
  33799: 3.75,
  37183: 3.375,
  3606: 1.25,
  2561: 3.8333334922790527,
  29960: 2.25,
  32397: 1.8333332538604736,
  39539: 2.5625,
  431: 2.25,
  36842: 2.3125,
  16926: 2.9166667461395264,
  9287: 3.3333334922790527,
  34246: 4.0,
  16277: 2.9166667461395264,
  34105: 1.5833333730697632,
  11032: 3.75,
  41457: 2.25,
  34380: 1.5833332538604736,
  19482: 3.9166665077209473,
  1844: 3.6666667461395264,
  9552: 3.25,
  35437: 3.0833332538604736,
  29555: 2.25,
  29993: 2.25,
  28114: 2.6666665077209473,
  15: 3.0,
  27712: 2.25,
  12313: 1.0833333730697632,
  11631: 2.5833334922790527},
 'step_bfi36_ab_cor': {33003: 2.8333332538604736,
  12172: 3.5,
  5192: nan,
  32511: 3.4166665077209473,
  7813: nan,
  21440: 2.4166665077209473,
  32912: 3.0,
  20609: 4.0,
  7751: 2.5,
  31228: 3.25,
  36230: 3.6875,
  32025: 1.875,
  21758: 1.9166666269302368,
  35730: 2.25,
  8444: 3.5833334922790527,
  19946: 4.333333492279053,
  37532: 3.3125,
  22926: 3.5,
  27204: 3.0833334922790527,
  31959: 3.0,
  24535: 2.5,
  19433: 4.083333492279053,
  17137: 2.25,
  26103: 2.1666665077209473,
  33878: 3.6666667461395264,
  39053: 3.25,
  33799: 3.75,
  37183: 3.375,
  3606: 4.25,
  2561: 2.8333334922790527,
  29960: 3.25,
  32397: 1.8333332538604736,
  39539: 2.5625,
  431: 2.25,
  36842: 3.0625,
  16926: 1.9166667461395264,
  9287: 0.3333333730697632,
  34246: 2.0,
  16277: 2.9166667461395264,
  34105: 3.5833334922790527,
  11032: 3.75,
  41457: 3.75,
  34380: 3.5833332538604736,
  19482: 3.9166665077209473,
  1844: 3.6666667461395264,
  9552: 3.25,
  35437: 3.0833332538604736,
  29555: 1.25,
  29993: 2.25,
  28114: 3.6666665077209473,
  15: 3.0,
  27712: 3.25,
  12313: 4.083333492279053,
  11631: 3.5833334922790527},
 'step_bfi39_ab_cor': {33003: 4.1666669845581055,
  12172: 3.5,
  5192: nan,
  32511: 4.583333492279053,
  7813: nan,
  21440: 2.5833334922790527,
  32912: 3.0,
  20609: 1.0,
  7751: 2.5,
  31228: 3.75,
  36230: 4.3125,
  32025: 1.125,
  21758: 4.083333492279053,
  35730: 2.75,
  8444: 3.4166665077209473,
  19946: 3.6666665077209473,
  37532: 2.4375,
  22926: 2.5,
  27204: 2.9166665077209473,
  31959: 3.0,
  24535: 1.5,
  19433: 2.9166665077209473,
  17137: 2.75,
  26103: 2.8333334922790527,
  33878: 3.3333332538604736,
  39053: 3.25,
  33799: 3.25,
  37183: 1.625,
  3606: 3.75,
  2561: 3.1666665077209473,
  29960: 3.75,
  32397: 3.1666667461395264,
  39539: 0.9375,
  431: 2.75,
  36842: 2.6875,
  16926: 3.0833332538604736,
  9287: 2.6666665077209473,
  34246: 3.0,
  16277: 4.0833330154418945,
  34105: 4.416666507720947,
  11032: 2.25,
  41457: 1.25,
  34380: 2.4166667461395264,
  19482: 1.0833333730697632,
  1844: 3.3333332538604736,
  9552: 1.75,
  35437: 3.9166667461395264,
  29555: 2.75,
  29993: 2.75,
  28114: 3.3333334922790527,
  15: 4.0,
  27712: 2.75,
  12313: 2.9166665077209473,
  11631: 2.4166665077209473}})

I defined a function to carry out a Cronbach's Alpha analysis, which has the following code:

def cronbach_alpha(df):
    # 1. Transform the df into a correlation matrix
    df_corr = df.corr()
    
    # 2.1 Calculate N
    # The number of variables equals the number of columns in the df
    N = df.shape[1]
    
    # 2.2 Calculate R
    # For this, we'll loop through the columns and append every
    # relevant correlation to an array calles "r_s". Then, we'll
    # calculate the mean of "r_s"
    rs = np.array([])
    for i, col in enumerate(df_corr.columns):
        sum_ = df_corr[col][i+1:].values
        rs = np.append(sum_, rs)
    mean_r = np.mean(rs)
    
   # 3. Use the formula to calculate Cronbach's Alpha 
    cronbach_alpha = (N * mean_r) / (1 + (N - 1) * mean_r)
    return cronbach_alpha

and now I'm very happy that I can get the Cronbach's alpha from my items using this command here:

cronbach_alpha(sim_data.drop("country",1))

However, I would like to have the Cronbach's alpha for all countries. My desired results is something like this result from R

R results

As you can see, it runs the Cronbach's alpha for all the items (15 items, from this dataset), but all analyses are grouped by each country. I'm pretty sure it can be done in Python and the user started to help me.

Upvotes: 3

Views: 176

Answers (1)

Trenton McKinney
Trenton McKinney

Reputation: 62583

  • Use pandas.DataFrame.groupby and .apply the function.
  • Ghana is Nan because there is only 1 row of valid data in the dataframe for that country.
  • The function cronbach_alpha only returns 1 value for a country when the dataframe for the country is provided.
cron = df.groupby('country', as_index=False).apply(cronbach_alpha).rename(columns={None: 'val'})

# display(cron)
        country       val
0       Armenia  0.918237
1       Bolivia  0.751889
2      Colombia -0.800000
3       Georgia  0.238676
4         Ghana       NaN
5         Kenya  0.746892
6          Laos  0.752618
7     Macedonia -0.800000
8   Philippines  0.569964
9        Serbia -0.675291
10    Sri_Lanka  0.916891
11      Ukraine -4.929153
12      Vietnam -0.668921
13       Yunnan  0.977778

get descriptive statistics for each country

df.groupby('country').describe()

[out]:
            step_bfi1_ab_cor                                                                       step_bfi3_ab_cor                                                                       step_bfi5_ab_cor                                                                       step_bfi6_ab_cor                                                                       step_bfi7_ab_cor                                                                       step_bfi10_ab_cor                                                                       step_bfi17_ab_cor                                                                       step_bfi19_ab_cor                                                                       step_bfi23_ab_cor                                                                       step_bfi30_ab_cor                                                                       step_bfi32_ab_cor                                                                       step_bfi33_ab_cor                                                                       step_bfi34_ab_cor                                                                       step_bfi36_ab_cor                                                                       step_bfi39_ab_cor                                                                      
                       count      mean       std       min       25%       50%       75%       max            count      mean       std       min       25%       50%       75%       max            count      mean       std       min       25%       50%       75%       max            count      mean       std       min       25%       50%       75%       max            count      mean       std       min       25%       50%       75%       max             count      mean       std       min       25%       50%       75%       max             count      mean       std       min       25%       50%       75%       max             count      mean       std       min       25%       50%       75%       max             count      mean       std       min       25%       50%       75%       max             count      mean       std       min       25%       50%       75%       max             count      mean       std       min       25%       50%       75%       max             count      mean       std       min       25%       50%       75%       max             count      mean       std       min       25%       50%       75%       max             count      mean       std       min       25%       50%       75%       max             count      mean       std       min       25%       50%       75%       max
country                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
Armenia                  3.0  3.277778  0.774298  2.416667  2.958333  3.500000  3.708333  3.916667              3.0  3.277778  0.718473  2.500000  2.958333  3.416667  3.666667  3.916667              3.0  2.611111  1.220011  1.500000  1.958333  2.416667  3.166667  3.916667              3.0  3.055556  0.891056  2.500000  2.541667  2.583333  3.333333  4.083333              3.0  2.944444  0.842999  2.416667  2.458333  2.500000  3.208333  3.916667               3.0  3.277778  0.718473  2.500000  2.958333  3.416667  3.666667  3.916667               3.0  2.611111  1.253698  1.416667  1.958333  2.500000  3.208333  3.916667               3.0  2.055556  0.843000  1.083333  1.791667  2.500000  2.541667  2.583333               3.0  3.722222  0.315495  3.500000  3.541667  3.583333  3.833333  4.083333               3.0  3.611111  0.267879  3.416667  3.458333  3.500000  3.708333  3.916667               3.0  3.611111  0.267879  3.416667  3.458333  3.500000  3.708333  3.916667               3.0  2.944444  0.842999  2.416667  2.458333  2.500000  3.208333  3.916667               3.0  3.277778  0.718473  2.500000  2.958333  3.416667  3.666667  3.916667               3.0  2.611111  0.809378  1.916667  2.166667  2.416667  2.958333  3.500000               3.0  3.055556  0.891056  2.500000  2.541667  2.583333  3.333333  4.083333
Bolivia                  3.0  3.305556  0.336788  3.000000  3.125000  3.250000  3.458333  3.666667              3.0  2.972222  0.292657  2.666667  2.833333  3.000000  3.125000  3.250000              3.0  2.305556  1.236969  1.250000  1.625000  2.000000  2.833333  3.666667              3.0  2.361111  0.851197  1.750000  1.875000  2.000000  2.666667  3.333333              3.0  2.638889  0.851197  1.666667  2.333333  3.000000  3.125000  3.250000               3.0  3.305556  0.336788  3.000000  3.125000  3.250000  3.458333  3.666667               3.0  2.638889  1.248147  1.250000  2.125000  3.000000  3.333333  3.666667               3.0  2.694444  1.424813  1.750000  1.875000  2.000000  3.166667  4.333333               3.0  3.694444  0.336788  3.333333  3.541667  3.750000  3.875000  4.000000               3.0  2.638889  1.434528  1.000000  2.125000  3.250000  3.458333  3.666667               3.0  3.305556  0.336788  3.000000  3.125000  3.250000  3.458333  3.666667               3.0  2.972222  0.708742  2.250000  2.625000  3.000000  3.333333  3.666667               3.0  2.972222  0.708742  2.250000  2.625000  3.000000  3.333333  3.666667               3.0  2.972222  0.708742  2.250000  2.625000  3.000000  3.333333  3.666667               3.0  3.361111  0.625463  2.750000  3.041667  3.333333  3.666667  4.000000
Colombia                 2.0  3.541667  1.001734  2.833333  3.187500  3.541667  3.895833  4.250000              2.0  3.541667  1.001734  2.833333  3.187500  3.541667  3.895833  4.250000              2.0  2.041667  0.294628  1.833333  1.937500  2.041667  2.145833  2.250000              2.0  2.958333  0.294628  2.750000  2.854167  2.958333  3.062500  3.166667              2.0  2.041667  0.294628  1.833333  1.937500  2.041667  2.145833  2.250000               2.0  2.541667  0.412479  2.250000  2.395833  2.541667  2.687500  2.833333               2.0  2.541667  2.415948  0.833333  1.687500  2.541667  3.395833  4.250000               2.0  2.958333  0.294628  2.750000  2.854167  2.958333  3.062500  3.166667               2.0  2.958333  0.294628  2.750000  2.854167  2.958333  3.062500  3.166667               2.0  3.541667  1.001734  2.833333  3.187500  3.541667  3.895833  4.250000               2.0  3.541667  1.001734  2.833333  3.187500  3.541667  3.895833  4.250000               2.0  2.541667  0.412479  2.250000  2.395833  2.541667  2.687500  2.833333               2.0  2.541667  1.826693  1.250000  1.895833  2.541667  3.187500  3.833333               2.0  3.541667  1.001734  2.833333  3.187500  3.541667  3.895833  4.250000               2.0  3.458333  0.412479  3.166667  3.312500  3.458333  3.604167  3.750000
Georgia                  4.0  2.333333  1.271118  0.916667  1.791667  2.208333  2.750000  4.000000              4.0  3.333333  0.784691  2.333333  2.895833  3.500000  3.937500  4.000000              4.0  1.583333  0.446177  1.083333  1.270833  1.625000  1.937500  2.000000              4.0  3.166667  0.627311  2.666667  2.854167  2.958333  3.270833  4.083333              4.0  2.083333  0.649073  1.333333  1.833333  2.041667  2.291667  2.916667               4.0  3.833333  0.531420  3.083333  3.708333  3.958333  4.083333  4.333333               4.0  2.833333  1.454559  1.000000  2.000000  3.125000  3.958333  4.083333               4.0  2.666667  1.156703  1.000000  2.437500  3.000000  3.229167  3.666667               4.0  3.666667  0.531420  2.916667  3.479167  3.833333  4.020833  4.083333               4.0  4.083333  0.180021  3.916667  3.979167  4.041667  4.145833  4.333333               4.0  4.083333  0.180021  3.916667  3.979167  4.041667  4.145833  4.333333               4.0  3.083333  1.215258  2.000000  2.062500  3.000000  4.020833  4.333333               4.0  2.833333  1.271118  1.000000  2.562500  3.208333  3.479167  3.916667               4.0  4.083333  0.180021  3.916667  3.979167  4.041667  4.145833  4.333333               4.0  2.166667  1.335068  1.000000  1.062500  2.000000  3.104167  3.666667
Ghana                    1.0  0.500000       NaN  0.500000  0.500000  0.500000  0.500000  0.500000              1.0  2.500000       NaN  2.500000  2.500000  2.500000  2.500000  2.500000              1.0  0.500000       NaN  0.500000  0.500000  0.500000  0.500000  0.500000              1.0  1.500000       NaN  1.500000  1.500000  1.500000  1.500000  1.500000              1.0  1.500000       NaN  1.500000  1.500000  1.500000  1.500000  1.500000               1.0  3.500000       NaN  3.500000  3.500000  3.500000  3.500000  3.500000               1.0  3.500000       NaN  3.500000  3.500000  3.500000  3.500000  3.500000               1.0  1.500000       NaN  1.500000  1.500000  1.500000  1.500000  1.500000               1.0  4.500000       NaN  4.500000  4.500000  4.500000  4.500000  4.500000               1.0  3.500000       NaN  3.500000  3.500000  3.500000  3.500000  3.500000               1.0  3.500000       NaN  3.500000  3.500000  3.500000  3.500000  3.500000               1.0  3.500000       NaN  3.500000  3.500000  3.500000  3.500000  3.500000               1.0  3.500000       NaN  3.500000  3.500000  3.500000  3.500000  3.500000               1.0  2.500000       NaN  2.500000  2.500000  2.500000  2.500000  2.500000               1.0  2.500000       NaN  2.500000  2.500000  2.500000  2.500000  2.500000
Kenya                    5.0  2.500000  0.677003  1.750000  2.250000  2.333333  2.583333  3.583333              5.0  3.700000  0.532291  3.250000  3.333333  3.583333  3.750000  4.583333              5.0  2.100000  1.024695  1.250000  1.333333  1.583333  2.750000  3.583333              5.0  3.100000  0.365148  2.666667  2.750000  3.250000  3.416667  3.416667              5.0  2.500000  0.677003  1.750000  2.250000  2.333333  2.583333  3.583333               5.0  3.300000  0.908295  2.333333  2.583333  3.250000  3.750000  4.583333               5.0  3.300000  0.341565  2.750000  3.250000  3.333333  3.583333  3.583333               5.0  3.300000  0.861201  2.416667  2.750000  3.250000  3.416667  4.666667               5.0  3.300000  0.974679  1.666667  3.416667  3.416667  3.750000  4.250000               5.0  3.100000  1.024695  2.250000  2.333333  2.583333  3.750000  4.583333               5.0  3.300000  0.570088  2.333333  3.250000  3.583333  3.583333  3.750000               5.0  3.300000  0.605530  2.250000  3.333333  3.583333  3.583333  3.750000               5.0  3.100000  0.508265  2.583333  2.583333  3.250000  3.333333  3.750000               5.0  2.900000  1.446260  0.333333  3.250000  3.583333  3.583333  3.750000               5.0  2.500000  0.612372  1.750000  2.250000  2.416667  2.666667  3.416667
Laos                     6.0  2.979167  1.050050  1.875000  2.250000  2.625000  3.937500  4.250000              6.0  3.312500  0.886531  2.250000  2.500000  3.562500  3.968750  4.250000              6.0  2.645833  0.867528  1.250000  2.156250  3.125000  3.250000  3.250000              6.0  2.854167  0.936805  1.750000  2.187500  2.750000  3.500000  4.125000              6.0  2.145833  0.726364  1.000000  1.968750  2.250000  2.250000  3.250000               6.0  2.312500  0.485734  1.875000  2.062500  2.250000  2.250000  3.250000               5.0  2.800000  0.512348  2.250000  2.250000  3.000000  3.250000  3.250000               6.0  2.187500  0.557618  1.750000  1.750000  1.937500  2.593750  3.000000               5.0  2.800000  0.111803  2.750000  2.750000  2.750000  2.750000  3.000000               6.0  2.979167  0.776276  1.875000  2.500000  3.250000  3.250000  4.000000               6.0  3.145833  0.166145  2.875000  3.062500  3.250000  3.250000  3.250000               6.0  2.979167  0.708946  2.000000  2.500000  3.250000  3.250000  3.875000               5.0  2.200000  0.111803  2.000000  2.250000  2.250000  2.250000  2.250000               6.0  2.479167  0.823167  1.250000  1.968750  2.625000  3.187500  3.250000               6.0  2.854167  0.963122  1.125000  2.750000  2.875000  3.562500  3.750000
Macedonia                2.0  1.791667  0.412479  1.500000  1.645833  1.791667  1.937500  2.083333              2.0  3.791667  0.412479  3.500000  3.645833  3.791667  3.937500  4.083333              2.0  0.791667  0.412479  0.500000  0.645833  0.791667  0.937500  1.083333              2.0  2.208333  1.001734  1.500000  1.854167  2.208333  2.562500  2.916667              2.0  2.791667  1.826693  1.500000  2.145833  2.791667  3.437500  4.083333               2.0  2.791667  1.001734  2.083333  2.437500  2.791667  3.145833  3.500000               2.0  2.291667  1.119586  1.500000  1.895833  2.291667  2.687500  3.083333               2.0  1.208333  0.412479  0.916667  1.062500  1.208333  1.354167  1.500000               2.0  3.208333  0.412479  2.916667  3.062500  3.208333  3.354167  3.500000               2.0  3.791667  0.412479  3.500000  3.645833  3.791667  3.937500  4.083333               2.0  2.291667  1.119586  1.500000  1.895833  2.291667  2.687500  3.083333               2.0  3.291667  0.294628  3.083333  3.187500  3.291667  3.395833  3.500000               2.0  1.291667  0.294628  1.083333  1.187500  1.291667  1.395833  1.500000               2.0  3.791667  0.412479  3.500000  3.645833  3.791667  3.937500  4.083333               2.0  3.208333  0.412479  2.916667  3.062500  3.208333  3.354167  3.500000
Philippines              3.0  2.687500  1.005842  1.750000  2.156250  2.562500  3.156250  3.750000              3.0  2.437500  0.165359  2.250000  2.375000  2.500000  2.531250  2.562500              3.0  2.187500  0.409840  1.750000  2.000000  2.250000  2.406250  2.562500              3.0  3.562500  0.933324  2.500000  3.218750  3.937500  4.093750  4.250000              3.0  3.687500  0.409840  3.250000  3.500000  3.750000  3.906250  4.062500               3.0  3.187500  0.907865  2.250000  2.750000  3.250000  3.656250  4.062500               3.0  2.687500  1.005842  1.750000  2.156250  2.562500  3.156250  3.750000               3.0  2.812500  0.409840  2.437500  2.593750  2.750000  3.000000  3.250000               3.0  2.312500  0.511585  1.750000  2.093750  2.437500  2.593750  2.750000               3.0  2.937500  1.685184  1.000000  2.375000  3.750000  3.906250  4.062500               3.0  2.187500  0.409840  1.750000  2.000000  2.250000  2.406250  2.562500               3.0  3.187500  0.634306  2.500000  2.906250  3.312500  3.531250  3.750000               3.0  2.437500  0.165359  2.250000  2.375000  2.500000  2.531250  2.562500               3.0  3.187500  0.596212  2.562500  2.906250  3.250000  3.500000  3.750000               3.0  1.812500  1.254679  0.937500  1.093750  1.250000  2.250000  3.250000
Serbia                   5.0  3.287500  0.721598  2.250000  2.937500  3.375000  3.812500  4.062500              5.0  2.987500  0.585302  2.250000  2.562500  3.062500  3.375000  3.687500              5.0  2.987500  0.900738  1.812500  2.250000  3.375000  3.687500  3.812500              5.0  2.762500  0.975681  1.250000  2.687500  2.812500  3.125000  3.937500              5.0  3.737500  0.247645  3.375000  3.687500  3.750000  3.812500  4.062500               5.0  2.987500  0.585302  2.250000  2.562500  3.062500  3.375000  3.687500               5.0  2.837500  0.688352  2.187500  2.312500  2.562500  3.375000  3.750000               5.0  2.612500  1.230631  0.937500  2.062500  2.687500  3.125000  4.250000               5.0  3.962500  0.489339  3.437500  3.562500  3.937500  4.250000  4.625000               5.0  3.437500  0.708487  2.250000  3.375000  3.687500  3.812500  4.062500               5.0  2.687500  0.601106  1.875000  2.250000  2.937500  3.062500  3.312500               5.0  3.437500  0.469791  2.937500  3.062500  3.375000  3.750000  4.062500               5.0  2.987500  0.585302  2.312500  2.562500  2.937500  3.375000  3.750000               5.0  3.137500  0.543786  2.250000  3.062500  3.312500  3.375000  3.687500               5.0  2.762500  0.975681  1.625000  2.437500  2.687500  2.750000  4.312500
Sri_Lanka                3.0  2.916667  1.543355  1.166667  2.333333  3.500000  3.791667  4.083333              3.0  2.916667  0.363242  2.500000  2.791667  3.083333  3.125000  3.166667              3.0  2.583333  1.401884  1.500000  1.791667  2.083333  3.125000  4.166667              3.0  2.083333  1.102396  0.833333  1.666667  2.500000  2.708333  2.916667              3.0  2.250000  0.794949  1.500000  1.833333  2.166667  2.625000  3.083333               3.0  2.583333  1.861526  0.500000  1.833333  3.166667  3.625000  4.083333               3.0  2.583333  0.463981  2.166667  2.333333  2.500000  2.791667  3.083333               3.0  2.083333  0.740683  1.500000  1.666667  1.833333  2.375000  2.916667               3.0  3.083333  0.682113  2.500000  2.708333  2.916667  3.375000  3.833333               3.0  3.583333  0.463981  3.166667  3.333333  3.500000  3.791667  4.083333               3.0  3.250000  0.794949  2.500000  2.833333  3.166667  3.625000  4.083333               3.0  2.583333  0.939119  1.500000  2.291667  3.083333  3.125000  3.166667               3.0  1.916667  0.363242  1.500000  1.791667  2.083333  2.125000  2.166667               3.0  2.583333  0.463981  2.166667  2.333333  2.500000  2.791667  3.083333               3.0  2.416667  0.794949  1.500000  2.166667  2.833333  2.875000  2.916667
Ukraine                  3.0  2.694444  0.693889  1.916667  2.416667  2.916667  3.083333  3.250000              3.0  3.027778  1.018350  1.916667  2.583333  3.250000  3.583333  3.916667              3.0  2.027778  0.192450  1.916667  1.916667  1.916667  2.083333  2.250000              3.0  2.305556  0.384900  2.083333  2.083333  2.083333  2.416667  2.750000              3.0  2.361111  0.509175  1.916667  2.083333  2.250000  2.583333  2.916667               3.0  3.361111  0.509175  2.916667  3.083333  3.250000  3.583333  3.916667               3.0  2.694444  0.384900  2.250000  2.583333  2.916667  2.916667  2.916667               3.0  2.638889  0.509175  2.083333  2.416667  2.750000  2.916667  3.083333               3.0  2.972222  0.192450  2.750000  2.916667  3.083333  3.083333  3.083333               3.0  3.027778  0.192450  2.916667  2.916667  2.916667  3.083333  3.250000               3.0  3.027778  0.192450  2.916667  2.916667  2.916667  3.083333  3.250000               3.0  2.361111  0.962250  1.250000  2.083333  2.916667  2.916667  2.916667               3.0  3.027778  0.192450  2.916667  2.916667  2.916667  3.083333  3.250000               3.0  2.361111  0.509175  1.916667  2.083333  2.250000  2.583333  2.916667               3.0  3.305555  0.693889  2.750000  2.916667  3.083333  3.583333  4.083333
Vietnam                 10.0  1.575000  0.868206  0.750000  1.020833  1.500000  1.645833  3.833333             10.0  3.375000  0.473446  2.583333  3.020833  3.500000  3.729167  4.000000             10.0  1.875000  0.661146  0.833333  1.604167  1.791667  2.312500  3.000000             10.0  3.025000  1.142643  1.166667  2.416667  2.958333  4.125000  4.333333             10.0  2.175000  0.878806  0.750000  1.645833  2.041667  2.645833  3.833333              10.0  2.975000  0.775841  1.750000  2.604167  3.041667  3.541667  4.000000              10.0  2.575000  0.604063  1.833333  2.020833  2.625000  2.812500  3.583333              10.0  2.825000  0.619201  1.583333  2.541667  3.083333  3.229167  3.416667              10.0  2.325000  1.038198  1.166667  1.541667  2.125000  2.854167  4.583333              10.0  2.775000  0.957467  0.750000  2.458333  2.916667  3.458333  4.000000              10.0  3.475000  0.490732  2.583333  3.166667  3.625000  3.812500  4.000000              10.0  3.275000  0.623671  1.833333  3.020833  3.500000  3.645833  4.000000              10.0  2.875000  0.929000  1.583333  2.041667  3.041667  3.666667  4.000000              10.0  3.075000  0.683187  1.833333  2.875000  3.250000  3.583333  3.750000              10.0  3.525000  0.707161  2.416667  3.041667  3.291667  4.104167  4.583333
Yunnan                   2.0  3.458333  0.294628  3.250000  3.354167  3.458333  3.562500  3.666667              2.0  2.958333  1.001734  2.250000  2.604167  2.958333  3.312500  3.666667              2.0  2.958333  0.412479  2.666667  2.812500  2.958333  3.104167  3.250000              2.0  2.541667  1.119586  1.750000  2.145833  2.541667  2.937500  3.333333              2.0  2.458333  1.708841  1.250000  1.854167  2.458333  3.062500  3.666667               2.0  3.458333  0.294628  3.250000  3.354167  3.458333  3.562500  3.666667               2.0  2.958333  1.001734  2.250000  2.604167  2.958333  3.312500  3.666667               2.0  3.041667  0.412479  2.750000  2.895833  3.041667  3.187500  3.333333               2.0  3.041667  0.412479  2.750000  2.895833  3.041667  3.187500  3.333333               2.0  3.458333  0.294628  3.250000  3.354167  3.458333  3.562500  3.666667               2.0  2.958333  1.001734  2.250000  2.604167  2.958333  3.312500  3.666667               2.0  2.458333  1.708841  1.250000  1.854167  2.458333  3.062500  3.666667               2.0  2.458333  0.294628  2.250000  2.354167  2.458333  2.562500  2.666667               2.0  3.458333  0.294628  3.250000  3.354167  3.458333  3.562500  3.666667               2.0  3.041667  0.412479  2.750000  2.895833  3.041667  3.187500  3.333333

Upvotes: 3

Related Questions