python - Pandas Data Frame function application to a specific row -
i'm trying apply 1 function f1 rows ['utah,'texas'] , f2 other rows. don't want create separate df each function. example adjusted wes mckinney's python data analysis: mwe: import pandas pd import numpy np frame = pd.dataframe(np.random.randn(4, 3), columns=list('bde'), index=['utah', 'ohio', 'texas', 'oregon']) f1 = lambda x: (x-x.min())/(x.max() - x.min()) f2 = lambda x: (x-x.max())/(x.min() - x.max()) i've tried selecting row label: frame.loc['utah'].apply(f1,axis=1) . i can feel small i'm missing but... this creates 2d numpy.array each row application of 1 of 2 functions dataframe according rules specified row: np.where( np.array([frame.index.isin(['utah', 'texas']) _ in frame.columns]).t, frame.apply(f1, axis=1), frame.apply(f2, axis=1)) since didn't specify output fully, it's hard guess want furt...