企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
选行或列: 使用name: `df.loc[['a','c'],['A','C']]` 使用 index: `df.iloc[[0,1,2],[0,1,2]])` ***** 选取单个 使用name: `df.at['c','A']` 使用index: `df.at[1,2]` ***** 1. [DataFrame.iterrows()](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.iterrows.html) ```python for index, row in df.iterrows(): print row["c1"], row["c2"] ``` 2. [DataFrame.apply()](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.apply.html) ``` def valuation_formula(x, y): return x * y * 0.5 df['price'] = df.apply(lambda row: valuation_formula(row['x'], row['y']), axis=1) ``` 3. DataFrame.iloc() ``` for i in range(0, len(df)): print df.iloc[i]['c1'], df.iloc[i]['c2'] ``` *****