A quick post representing code sample on how to print unique values in Dataframe columns in Pandas. Here is a data frame comprising of oil prices on different dates which column such as year comprising of repeated/duplicate value of years.
In the above data frame, the requirement is to print the unique value of year column. Here is the code for same. Note the method unique()
for year in df['year'].unique(): print(year)
Latest posts by Ajitesh Kumar (see all)
- Underwriting & Machine Learning Models Examples - June 8, 2023
- Matplotlib Bar Chart Python / Pandas Examples - June 7, 2023
- One-hot Encoding Concepts & Python Examples - June 6, 2023
Leave a Reply