You could use loc
to get series which satisfying your condition and then iloc
to get first element:
In [2]: df
Out[2]:
A B
0 p1 1
1 p1 2
2 p3 3
3 p2 4
In [3]: df.loc[df['B'] == 3, 'A']
Out[3]:
2 p3
Name: A, dtype: object
In [4]: df.loc[df['B'] == 3, 'A'].iloc[0]
Out[4]: 'p3'
More Related Contents:
- how to calculation cost time [closed]
- How to add a new column to an existing DataFrame?
- String concatenation of two pandas columns
- pandas: filter rows of DataFrame with operator chaining
- Reshape wide to long in pandas
- How do I create test and train samples from one dataframe with pandas?
- Pandas – Slice large dataframe into chunks
- What is the difference between using loc and using just square brackets to filter for columns in Pandas/Python?
- python – Using pandas structures with large csv(iterate and chunksize)
- Group duplicate column IDs in pandas dataframe
- How to convert column with list of values into rows in Pandas DataFrame
- Remove or replace spaces in column names
- Python – splitting dataframe into multiple dataframes based on column values and naming them with those values [duplicate]
- Shift NaNs to the end of their respective rows
- how to read certain columns from Excel using Pandas – Python
- OSError: Initializing from file failed on csv in Pandas
- Convert column to row in Python Pandas
- Putting many python pandas dataframes to one excel worksheet
- Remove Unnamed columns in pandas dataframe [duplicate]
- How to slice a pandas DataFrame by position?
- Filling in date gaps in MultiIndex Pandas Dataframe
- Writing a Python Pandas DataFrame to Word document
- Find unique values in a Pandas dataframe, irrespective of row or column location
- Efficient way to add rows to dataframe
- Find names of top-n highest-value columns in each pandas dataframe row
- Convert pandas DataFrame into list of lists [duplicate]
- Got continuous is not supported error in RandomForestRegressor
- Copy text between parentheses in pandas DataFrame column into another column
- Get frequency of item occurrences in a column as percentage [duplicate]
- Get max value from row of a dataframe in python [duplicate]