Skip to content Skip to sidebar Skip to footer

Return DataFrame Item Using Partial String Match On Rows Pandas Python

I have a Dataframe of two columns, with strings in one column and lists in the other, as below: RSD_TYPE FILTER LIST 0 AQ500 [N

Solution 1:

Try this:

df[df['RSD_TYPE'].str.contains("AQ5")]['FILTER LIST']

Example:

In [3]: df
Out[3]:
   RSD_TYPE                                FILTER LIST
0     AQ500          [N/A, Z mean, SNR mean, Dir mean]
1    Triton  [wipe mean, Z mean, Avail mean, Dir mean]
2  Windcube            [N/A, W mean, Q mean, Dir mean]
3    Zephir     [Rain mean, W mean, Packets, dir mean]

[4 rows x 2 columns]

In [4]: df[df['RSD_TYPE'].str.contains("AQ5")]
Out[4]:
  RSD_TYPE                        FILTER LIST
0    AQ500  [N/A, Z mean, SNR mean, Dir mean]

[1 rows x 2 columns]

In [5]: df[df['RSD_TYPE'].str.contains("AQ5")]['FILTER LIST']
Out[5]:
0    [N/A, Z mean, SNR mean, Dir mean]
Name: FILTER LIST, dtype: object

Post a Comment for "Return DataFrame Item Using Partial String Match On Rows Pandas Python"