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 :: install python 3.7 centos 
Python :: python swap two values in list 
Python :: how to append list to list in python 
Python :: dataframe from dict 
Python :: python glob 
Python :: make a window tkinter 
Python :: python sleep 1 second 
Python :: how to export DataFrame to CSV file 
Python :: setting p a virtual envioronment 
Python :: Save a Dictionary to File in Python Using the dump Function of the pickle Module 
Python :: conda python update 
Python :: python if elif else in one line 
Python :: pandas delete column by name 
Python :: pandas strip whitespace 
Python :: index in list 
Python :: python reversed range 
Python :: django month name from month number 
Python :: string remove everything after character python 
Python :: convert dictionary keys/values to lowercase in python 
Python :: lexicographic order python 
Python :: append in a for loop python 
Python :: plt.imread python 
Python :: print pattern a shape in python 
Python :: fstring 
Python :: generate a random letter using python 
Python :: python for k, v in dictionary 
Python :: find character in python 
Python :: python numpy array change axis 
Python :: extract tgz files in python 
Python :: python-telegram-bot 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =