0

I have a dataframe:

import pandas as pd

data = {'Name': ['car', 'car', 'truck', 'car'],
        'SysNum': [1, 2, 3, 4 ]
            }

df = pd.DataFrame(data)

The output looks like:

    Name    SysNum
0   car     1
1   car     2
2   truck   3
3   car     4

I want to be able to loop over this data frame and create a third column that combines the two columns together and look like:

    Name    SysNum  Count
0   car     1       car1
1   car     2       car2
2   truck   3       truck3
3   car     4       car4

The loop is much longer than this but I am struggling to create a decent loop that results in this third column. So say there are 50 cars I need the loop to be the length of 50 and combine each row together.

JakeP
  • 69
  • 5

0 Answers0