1 Reply Latest reply on May 2, 2019 12:36 AM by Tim Beard

    Counting repetition in 2 different columns

    Juliana Almeida

      I'm trying to count repetitions in 2 different columns since they have elements in common, not having success. In Python pandas I use

       

      tour.sort_values(by=['Origin','Destination'])

      origin = tour["Origin"].value_counts()

      destination = tour["Destination"].value_counts()

      pop_cities = origin + destination

      pop_cities_bar = pop_cities.sort_values(ascending=[False]).head(5)

      pop_cities_bar.plot.bar()

      print('Top 5 most popular cities')

       

      Any ideas?