How to use 'pandas select row by index' in Python

Every line of 'pandas select row by index' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
525def get_selection_by_index(df, position, orientation='side'):
526 '''
527 Grabs and returns a single column or row.
528 example: myrow = get_selection_by_index(mydf, 2, 'side')
529 grabs row 2 from df.
530 '''
532 if orientation == 'side':
533 #will return a single row
534 df = df.ix[[position],:]
535 else:
536 #will return a single col
537 df = df.ix[:,[position]]
539 return df
74def _select(a, indexes):
75 return [h for h, i in zip(a, range(len(a))) if i in indexes]

Related snippets