'How to exclude a column/ field ('ID') from the showing amongst value counts using Python?

I'm looking to list the value count per each 'object' and 'int64' column/ field. However, customer ID 'ID' is an int64 column. I'd like to exclude this from my output. What is the simplest and most efficient way to do so?

Below is my current/ written script followed by its output.

for c in df.select_dtypes('object' and 'int64').columns:
        print(f"{c}: \n\n{df[c].value_counts()}\n")

enter image description here

Do let me know if you need clarification as to my objective or additional comments.



Solution 1:[1]

for c in df.select_dtypes(['object','int64']).columns:
    if c != 'ID':
        print(f"{c}: \n\n{df[c].value_counts()}\n")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TheTwo