0

I have a dataframe, df:

col_name    col_value
abc         34
def         0.76
lmn         6
xyz         80

I want to create a series by selecting 2 values of col_name column in df: ind = ['abc', 'def']

what i tried so far:

ind = ['abc', 'def']
x = pd.Series(df['value', index = ind]
sparkstars
  • 87
  • 6
  • Looks like `df.loc[df['col_name'].isin(ind), 'col_value']` or `df[df['col_name'].isin(ind)].set_index('col_name')` – Henry Ecker Sep 09 '21 at 00:19

0 Answers0