Skip to content
Advertisement

Tag: duplicates

Print the duplicate values from a dictionary in Python

I just wonder if it’s possible to print the duplicate values from a dictionary. For exemple I have this dictonary: So if I pick two different keys like: They have a common coffee name like: Purity Coffee Flow, Out Of The Grey Costa Rica La Minita So if I insert the keys for it like: chocolate, medium. The program need

Create pandas dataframe on column name conditions

Python newbie attempting a complex pandas dataframe logic I have multiple dataframes I need to join but I’ll show two below for the example. The dataframe have duplicate columns labelled with suffix ‘_duplicate’. I need to replicate the row instead of having the duplicate column as seen below. My first thought is to get a list of unique column names

Remove duplicate value on nested list python

I have a problem here when I want to remove duplicate in a list that has a nested list, how can I remove the duplicate value from list? What I got here from my script, it can remove a duplicate, but the nested list has a different result from what I expect. This is my script: Result: Expected Result: Answer

Python – Trouble printing to CSV

My code seems to be outputting the list I want, however, when I try printing the list to CSV I do not get the same result on the .csv file for some reason. I am sure there’s something not right at the end of my code. Could anyone please shed some light? Thanks in advance. Answer I have not used

Extract data from pandas dataframe columns with duplicate names

I have a dataframe which has duplicate column names: …and want to convert it into two dataframes; one only of “Accepted” columns and other for “Reject” Columns: df1: df2: Tried: … but this only gives the first column matching this name. Answer If select one column with same name are selected all columns with same name in DataFrame: Then is

How to use applymap lambda with two conditions

I’d like to find duplicated rows in a Pandas dataframe. When I use df.duplicated() it returns the following error: TypeError: unhashable type: ‘list’ To resolve this error, I tried the following: However, I receive a new but similar error: “TypeError: unhashable type: ‘dict'” Does anyone know how I can use applymap lambda with two conditions? (the conditions are if isinstance(x,

Advertisement