Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

find index of pandas column

In [45]: df = DataFrame({"pear": [1,2,3], "apple": [2,3,4], "orange": [3,4,5]})

In [46]: df.columns
Out[46]: Index([apple, orange, pear], dtype=object)

In [47]: df.columns.get_loc("pear")
Out[47]: 2
Comment

finding the index of an element in a pandas df

In [48]: a
Out[48]: 
   c1  c2
0   0   1
1   2   3
2   4   5
3   6   7
4   8   9

In [49]: a.c1[a.c1 == 8].index.tolist()
Out[49]: [4]
Comment

finding the index of an item in a pandas df

print(df[df['Name']=='Donna'].index.values)
Comment

get index number pandas dataframe

df.index[df['BoolCol'] == True].tolist()
Comment

how to get index of pandas dataframe python

import pandas as pd

df = pd.DataFrame(
    [[88, 72, 67],
    [23, 78, 62],
    [55, 54, 76]],
    index=[2, 4, 9],
    columns=['a', 'b', 'c'])

index = df.index
print(index)
Comment

get index of dataframe

df.index
Comment

how to get index of pandas dataframe python

DataFrame.index
Comment

PREVIOUS NEXT
Code Example
Python :: python pandas series to dataframe 
Python :: pandas iterate columns 
Python :: python turtle background image 
Python :: how to convert multi list to dict 
Python :: python webdriver open with chrome extension 
Python :: facerecognizer python 
Python :: from django.utils.translation import ugettext_lazy as _ 
Python :: filter dataframe 
Python :: get last day of month python 
Python :: python code formatter vs code 
Python :: python ceil 
Python :: post request python 
Python :: gnome-shell turn off 
Python :: check nan values in a np array 
Python :: find the max value in dictionary python 
Python :: python deque 
Python :: if keyboard.is_pressed 
Python :: First Unique Character in a String in python 
Python :: scikit learn k means 
Python :: how to check if python is 32 or 64 bit 
Python :: pd get non-numeric columns 
Python :: how to make a full pyramid in python 
Python :: how to create a role and give it to the author discord.py 
Python :: What happens when you use the built-in function any() on a list? 
Python :: python from timestamp to string 
Python :: create models in django 
Python :: generate sha1 python 
Python :: read a file and split the words python 
Python :: how to disable resizing in tkinter 
Python :: python script header 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =