I’ve tried multiple ways to make this work, but am still learning at pandas. Assume the following dataset:
Name Version Item
Foo Alpha Washington
Foo Alpha Adams
Foo Bravo Jefferson
Foo Bravo Madison
Bar Alpha Monroe
Bar Alpha Quincy
Bar Bravo Jackson
Bar Bravo Buren
I’m looking to create a column that would represent a unique combination of Name
and Version
, and then another that would represent a unique Item
per the first unique combination. The resulting data frame would look as follows:
Name Version Item Name Num Item Num
Foo Alpha Washington 1 1
Foo Alpha Adams 1 2
Foo Bravo Jefferson 2 1
Foo Bravo Madison 2 2
Bar Alpha Monroe 3 1
Bar Alpha Quincy 3 2
Bar Bravo Jackson 4 1
Bar Bravo Buren 4 2
I know this is fairly straightforward, but I’m stuck. I’ve been trying to use various combinations of reindex
, set_index
and reset_index
, but I’m just flailing as I don’t yet grok pandas…
Any help would be appreciated!