Skip to content

Tag: duplicates

Pandas – Duplicate Rows and Slice String

I’m trying to create duplicate rows during a dataframe on conditions. For example, I have this Dataframe. And I would like to get the following output: Answer For pandas 0.25+ is possible use DataFrame.explode with splitted values by Series.str.split and for remark column list comprehension with filteri…

Count duplicate lists inside a list

I want the result to be 2 since number of duplicate lists are 2 in total. How do I do that? I have done something like this But the count value is 1 as it returns matched lists. How do I get the total number of duplicate lists? Answer Solution You can use collections.Counter if your sub-lists only contain num…

Checking if a list has duplicate lists

Given a list of lists, I want to make sure that there are no two lists that have the same values and order. For instance with my_list = [[1, 2, 4, 6, 10], [12, 33, 81, 95, 110], [1, 2, 4, 6, 10]] it is supposed to return me the existence of duplicate lists, i.e. [1, 2, 4, 6, 10].