looping in a pd dataframe col, print the unique value of its ol
Jump to turn (10)
- 1looping in a pd dataframe col, print the unique value of its ol
- 2print the n number of dataframe
- 3if exact one number?
- 4print the dataframe if match one condition in one cols with specail value
- 5sqlalcemy filter
- 6async def filtering( filterparams: modelFilterParams, db: Session = Depends(getd
- 7show me in code on how to mod
- 8this method will cause too much on user typing many value, can use "" to represe
- 9please make this change into my code
- 10there is no replace fucntion
- User
looping in a pd dataframe col, print the unique value of its ol
- Assistant
To print the unique values of a particular column in a pandas dataframe, you can use the
uniquefunction. Here's an example:pythonimport pandas as pd # create example dataframe df = pd.DataFrame({'Name': ['Alice', 'Bob', 'Charlie', 'Alice', 'Bob'], 'Age': [25, 30, 35, 25, 30], 'Salary': [50000, 60000, 70000, 50000, 55000]}) # loop through unique values of Salary column and print them for salary in df['Salary'].unique(): print(salary)This will output:
code50000 60000 70000 55000