How to filter Pandas DataFrame by values of columns?

0 votes

Hi Guys,

I have a Dataframe in Pandas. I want to filter the DataFrame by values of columns. How can I do that?

Oct 20 in Python by akhtar
• 33,120 points
28 views

1 answer to this question.

0 votes

Hi@akhtar,

You can filter Pandas Dataframe with the loc function. For example, to find the instances in a pandas Dataframe where the values of a column are between some values (‘A’ and ‘B’), you can use:

filtered_df = df.loc[(df['col'] >= A) & (df['col'] <= B)] 
    answered Oct 20 by MD
    • 78,020 points

    Related Questions In Python

    0 votes
    1 answer

    How to print all the index of Pandas Dataframe?

    Try this: print(df.index.values) READ MORE

    answered Apr 8, 2019 in Python by Yogi
    339 views
    0 votes
    1 answer

    How to find the sum of rows in Pandas dataframe?

    You can use a combination groupby function with the sum() method. ...READ MORE

    answered May 9, 2019 in Python by Jisha
    2,382 views
    +1 vote
    2 answers
    0 votes
    1 answer

    How to print the index of a Pandas Dataframe?

    You can do this using the code ...READ MORE

    answered May 12, 2019 in Python by Usha
    4,818 views
    0 votes
    1 answer
    0 votes
    1 answer

    How to create Pandas series from dictionary?

    Here's a sample script: import pandas as pd import ...READ MORE

    answered Apr 1, 2019 in Python by Prateek
    521 views
    0 votes
    1 answer

    Python: Issue with 'unexpected end of pattern'

    I should start by stating that using ...READ MORE

    answered Sep 12, 2018 in Python by Priyaj
    • 57,700 points
    568 views
    0 votes
    1 answer

    Python: Issue with 'unexpected end of pattern'

    I should start by stating that using ...READ MORE

    answered Sep 24, 2018 in Python by Priyaj
    • 57,700 points
    478 views
    0 votes
    1 answer

    How to change the order of DataFrame columns in pandas?

    Hi@akhtar, You can rearrange a DataFrame object by ...READ MORE

    answered Oct 20 in Python by MD
    • 78,020 points
    34 views
    +1 vote
    2 answers

    How to change/update cell value in Python Pandas dataframe?

    You can use the at() method to ...READ MORE

    answered Apr 8, 2019 in Python by Kunal
    88,631 views