Crunch-io / scrunch

Pythonic scripting library for cleaning data in Crunch
GNU Lesser General Public License v3.0
5 stars 6 forks source link

ds.copy_variabe() mixes up subvariable names for multiple_response #230

Closed jamesrkg closed 6 years ago

jamesrkg commented 6 years ago

When using ds.copy_variable() to copy a multiple_response the resulting subvariable names end up in the wrong place.

new_var = ds.copy_variable(
    ds['Q3'],
    alias='Q3_dp',
    name='Q3_dp'
)

List the id and name for each subvariable in the original Q3 and give their frequencies:

0001 Tokopedia
0002 Lazada
0003 Berrybenka
0004 Hijabenka
0005 Bukalapak
0006 Sale Stock
0007 JD.ID
0008 Zalora
0009 Blibli.com
0010 Shopee
0011 Elevenia
0012 hijup.com
0013 Mataharimall.com
0014 Pomelo
0015 mapemall.com
0016 Online shop di social media seperti Instagram/ Facebook
0017 Lainnya:

id           1     2  9  8
Q3 Q3_1   1363   152  0  0
   Q3_2   1385   130  0  0
   Q3_3   1017   498  0  0
   Q3_4    804   711  0  0
   Q3_5   1249   266  0  0
   Q3_6    963   552  0  0
   Q3_7   1023   492  0  0
   Q3_8   1308   207  0  0
   Q3_9   1209   306  0  0
   Q3_10  1421    94  0  0
   Q3_11  1151   364  0  0
   Q3_12   588   927  0  0
   Q3_13  1150   365  0  0
   Q3_14   322  1193  0  0
   Q3_16   160  1355  0  0
   Q3_15   750   765  0  0
   Q3_98    25  1490  0  0

Liarinf the id and name for each subvariable in the resulting Q3_dp and give their frequencies:

0001 Berrybenka
0002 hijup.com
0003 Hijabenka
0004 Bukalapak
0005 Mataharimall.com
0006 Tokopedia
0007 Elevenia
0008 Zalora
0009 Blibli.com
0010 Lazada
0011 Lainnya:
0012 mapemall.com
0013 Pomelo
0014 Sale Stock
0015 Online shop di social media seperti Instagram/ Facebook
0016 JD.ID
0017 Shopee

id                 1     2  9  8
Q3_dp Q3_dp_3   1363   152  0  0
      Q3_dp_12  1385   130  0  0
      Q3_dp_4   1017   498  0  0
      Q3_dp_5    804   711  0  0
      Q3_dp_13  1249   266  0  0
      Q3_dp_1    963   552  0  0
      Q3_dp_11  1023   492  0  0
      Q3_dp_8   1308   207  0  0
      Q3_dp_9   1209   306  0  0
      Q3_dp_2   1421    94  0  0
      Q3_dp_98  1151   364  0  0
      Q3_dp_16   588   927  0  0
      Q3_dp_14  1150   365  0  0
      Q3_dp_6    322  1193  0  0
      Q3_dp_15   160  1355  0  0
      Q3_dp_7    750   765  0  0
      Q3_dp_10    25  1490  0  0

FYI convenience I am using the function given here to generate those frequencies.

jamesrkg commented 6 years ago

I wonder if this will naturally resolve with #86.

jamesrkg commented 6 years ago

I've tested this again following #86 and it does appear to be resolved, so I'm closing this ticket.

jamesrkg commented 6 years ago

Re-opening this - it's actually not solved after all.

mathiasbc commented 6 years ago

Old code we had in place that took care of naming subvariables of he copied variable. This is no longer the case as Crunch now takes care of that. Fixed in: https://github.com/Crunch-io/scrunch/commit/f4993e529ffd737b5601dd2d917157783653bfce