Skip to main content
Tweeted twitter.com/StackMma/status/953119830911209472
deleted 12 characters in body
Source Link
ramesh
  • 2.3k
  • 17
  • 29

I copied the title and concept for this question from here. I have

data = {{"ID", "Value"}, {1, 48}, {1, 45}, {1, 52}, {1, 43}, {1, 
    41}, {2, 50}, {2, 42}, {2, 51}, {2, 52}, {bb, 52}, {bb, 54}, {ccdd, 
    3020}, {dd, 2025}, {dd, 2527}, {ddcc, 2730}};

I want to create a new column called "Count" so that:

result = {{"ID", "Value", "Count"}, {1, 48, 1}, {1, 45, 2}, {1, 52, 
    3}, {1, 43, 4}, {1, 41, 5}, {2, 50, 1}, {2, 42, 2}, {2, 51, 
    3}, {2, 52, 4}, {bb, 52, 1}, {bb, 54, 2}, {ccdd, 3020, 1}, {dd, 2025, 
    12}, {dd, 2527, 23}, {ddcc, 2730, 31}};

I have a huge data with almost 2 billion observations. Therefore, efficient coding would save a lot of time and energy. As always, help is much appreciated. Thanks

I copied the title and concept for this question from here. I have

data = {{"ID", "Value"}, {1, 48}, {1, 45}, {1, 52}, {1, 43}, {1, 
    41}, {2, 50}, {2, 42}, {2, 51}, {2, 52}, {bb, 52}, {bb, 54}, {cc, 
    30}, {dd, 20}, {dd, 25}, {dd, 27}};

I want to create a new column called "Count" so that:

result = {{"ID", "Value", "Count"}, {1, 48, 1}, {1, 45, 2}, {1, 52, 
    3}, {1, 43, 4}, {1, 41, 5}, {2, 50, 1}, {2, 42, 2}, {2, 51, 
    3}, {2, 52, 4}, {bb, 52, 1}, {bb, 54, 2}, {cc, 30, 1}, {dd, 20, 
    1}, {dd, 25, 2}, {dd, 27, 3}};

I have a huge data with almost 2 billion observations. Therefore, efficient coding would save a lot of time and energy. As always, help is much appreciated. Thanks

I copied the title and concept for this question from here. I have

data = {{"ID", "Value"}, {1, 48}, {1, 45}, {1, 52}, {1, 43}, {1, 
    41}, {2, 50}, {2, 42}, {2, 51}, {2, 52}, {bb, 52}, {bb, 54}, {dd, 
    20}, {dd, 25}, {dd, 27}, {cc, 30}};

I want to create a new column called "Count" so that:

result = {{"ID", "Value", "Count"}, {1, 48, 1}, {1, 45, 2}, {1, 52, 
    3}, {1, 43, 4}, {1, 41, 5}, {2, 50, 1}, {2, 42, 2}, {2, 51, 
    3}, {2, 52, 4}, {bb, 52, 1}, {bb, 54, 2}, {dd, 20, 1}, {dd, 25, 
    2}, {dd, 27, 3}, {cc, 30, 1}};

I have a huge data with almost 2 billion observations. Therefore, efficient coding would save a lot of time and energy. As always, help is much appreciated. Thanks

Source Link
ramesh
  • 2.3k
  • 17
  • 29

How can I create an enumeration variable by groups?

I copied the title and concept for this question from here. I have

data = {{"ID", "Value"}, {1, 48}, {1, 45}, {1, 52}, {1, 43}, {1, 
    41}, {2, 50}, {2, 42}, {2, 51}, {2, 52}, {bb, 52}, {bb, 54}, {cc, 
    30}, {dd, 20}, {dd, 25}, {dd, 27}};

I want to create a new column called "Count" so that:

result = {{"ID", "Value", "Count"}, {1, 48, 1}, {1, 45, 2}, {1, 52, 
    3}, {1, 43, 4}, {1, 41, 5}, {2, 50, 1}, {2, 42, 2}, {2, 51, 
    3}, {2, 52, 4}, {bb, 52, 1}, {bb, 54, 2}, {cc, 30, 1}, {dd, 20, 
    1}, {dd, 25, 2}, {dd, 27, 3}};

I have a huge data with almost 2 billion observations. Therefore, efficient coding would save a lot of time and energy. As always, help is much appreciated. Thanks