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]: dfOut[3]:
   RSD_TYPEFILTERLIST0AQ500[N/A, Z mean, SNR mean, Dir mean]1Triton[wipe mean, Z mean, Avail mean, Dir mean]2Windcube[N/A, W mean, Q mean, Dir mean]3Zephir[Rain mean, W mean, Packets, dir mean][4 rows x 2 columns]

In[4]: df[df['RSD_TYPE'].str.contains("AQ5")]
Out[4]:
  RSD_TYPEFILTERLIST0AQ500[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: FILTERLIST, dtype: object

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