I got a table like that :
house
house
house
dog
dog
dog
And I would like to have only first occurence of each different words. So I would like to have a column like that
house house
house
house
dog dog
dog
dog
thanks for reading me
>Solution :
If it is a dataframe, you can use:
df.column_name.unique()
if it is a numpy array:
np.unique(array)
If it is a list:
unique = list(set(data))
If you don’t have the full data and it depends on anything else, you can use a function like:
# initialize a null list
unique_list = []
# traverse for all elements
for x in data: # read the data
# check if exists in unique_list or not
if x not in unique_list:
unique_list.append(x)