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 :: how to add color to python text 
Python :: python kill process by name 
Python :: How many columns have null values present in them? in pandas 
Python :: python change column order in dataframe 
Python :: Math Module log() Function in python 
Python :: adding columns in cpecific position 
Python :: find by class bs4 
Python :: python program to add two numbers 
Python :: django form set min and max value 
Python :: python big comment 
Python :: how to read text frome another file pythion 
Python :: pyautogui color 
Python :: python3 change file permissions 
Python :: connection to server at "" (), port 5432 failed: timeout expired 
Python :: python ascii 
Python :: check tf verison 
Python :: jupyter upload folder 
Python :: shutil copyfile python 
Python :: python cv2 get image shape 
Python :: how to fill a list in python 
Python :: how do i print a list line by line in python 
Python :: python dict sort by value 
Python :: Inconsistent use of tabs and spaces in indentationPylance 
Python :: how to redirect in django rest framework 
Python :: copy a dict in python 
Python :: or condition in pandas 
Python :: tkinter messagebox 
Python :: tkinter menus 
Python :: how to get input from list in python 
Python :: plotting two columns of a dataframe in python 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =