i have this code
pd.unique(df_dataset["City"])
then this output comes out
array(['Marseile', 'Barcelona', 'Valencia', 'Paris', 'Berlin', 'Lyon',
'Seville', 'Palma', 'Munich', 'Hamburg', 'Madrid', 'Nice',
'Granada'], dtype=object)
how do i add sort() function in the code
I have tried to run this
pd.unique(df_dataset["City"]).sorted("City", key=True)
but it doesn't seems correct
Let us just with pandas
df_dataset["City"].sort_values().unique()
What about:
sorted(df_dataset["City"].unique())
If you want to keep the numpy.array type:
import numpy as np
np.sort(df_dataset["City"].unique())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With