Consider a data frame with row names that aren't a column of their own per se, such as the following:
X Y Row 1 0 5 Row 2 8 1 Row 3 3 0
How would I extract the name of these rows as a list, if I have their index? For example, it would look something like:
function_name(dataframe[indices]) > ['Row 1', 'Row 2']
Get Row Index Label Names from a DataFrame object listOfRowIndexLabels is a list that contains all the row index labels of a DataFrame object i.e. As df. index. values is a ndarray, so we can access it contents by position too.
You can select a single row from pandas DataFrame by integer index using df. iloc[n] . Replace n with a position you wanted to select.
df.index
Index
object. list(df.index)
df.index['Row 2':'Row 5']
this seems to work fine :
dataframe.axes[0].tolist()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With