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 :: Import CSV Files into R Using fread() method 
Python :: django add model 
Python :: Column names reading csv file python 
Python :: how to take unknown number of inputs in python 
Python :: error urllib request no attribute 
Python :: python how to change an element in a multi dimensional list 
Python :: python read line into list 
Python :: python empty dictionary 
Python :: len of int python 
Python :: python largest value in list 
Python :: read a file and split the words python 
Python :: phone number regex python 
Python :: python list except last element 
Python :: pynput.keyboard.Key 
Python :: discord py get channel id by name 
Python :: how to execute python program in ubuntu 
Python :: python set negative infinity 
Python :: binary to decimal in python 
Python :: remove comments from python file 
Python :: 2 for loops at the same time in Python 
Python :: pytorch freeze layers 
Python :: python optionmenu tkinter 
Python :: import django-on-heroku 
Python :: model o weight 
Python :: python select columns with no na 
Python :: numpy datetime64 get day 
Python :: converting binary to octal in python 
Python :: pandas convert series of datetime to date 
Python :: add to middle of list python 
Python :: download images python google 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =