Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to select a single cell in a pandas dataframe

# how to select a single cell in a pandas dataframe

import pandas as pd

old = pd.DataFrame({'A' : [4,5], 'B' : [10,20], 'C' : ['cell wanted',50], 'D' : [-30,-50]})
var = old['C'].values[0]

print(var)
Comment

python return value from single cell dataframe

import pandas as pd

data = ["thing"]
df = pd.DataFrame(data)

print(df.values)
print(df.values[0])
print(df.values[0][0]) #Get first element each time you want to remove the "[]" from a SINGLE value

>>>[['thing']]
>>>['thing']
>>>'thing'
Comment

PREVIOUS NEXT
Code Example
Python :: Access item in a list of lists 
Python :: run python file from another python file 
Python :: python thread with return values? 
Python :: python combine two lists into matrix 
Python :: python get substring between strings 
Python :: Python create point from coordinates 
Python :: python variable declare 
Python :: use django taggit in template 
Python :: python get current date 
Python :: pandas isin 
Python :: pandas replace nan with none 
Python :: pandas remove outliers 
Python :: python create array 
Python :: how to get user id django 
Python :: reverse python 
Python :: split pandas dataframe in two 
Python :: python tkinter cursor types 
Python :: print with no newline 
Python :: Converting categorical feature in to numerical features using target ordinary encoding 
Python :: hashlib sha 256 
Python :: python delete from dictionary 
Python :: drop first column read_csv 
Python :: np.mean 
Python :: python get the intersection of two lists 
Python :: numpy merge 
Python :: python int16 
Python :: torch.stack example 
Python :: python uuid 
Python :: cumulative frequency for python dataframe 
Python :: time difference between two datetime.time 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =