Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas get tuples from dataframe

# adapted from Stack Overflow user answer in the source link
import pandas as pd
df = pd.DataFrame({"A" : [1, 1, 2, 2], "B" : [3, 4, 3, 4]})
tuples = [tuple(x) for x in df.to_numpy()]
tuples
>>> [(1, 3), (1, 4), (2, 3), (2, 4)]
Comment

PREVIOUS NEXT
Code Example
Python :: run a for loop in python 
Python :: string in python 
Python :: how to use a class in python 
Python :: Maximize Difference codechef solution 
Python :: use get method request html page python 
Python :: python list include 
Python :: python types of loops 
Python :: # Python string capitalization 
Python :: change every element of list python with map 
Python :: switch case python 3.10 
Python :: read variable in a string python 
Python :: Generate bootstrap sample 
Python :: python construct a string 
Python :: insert an element in list python 
Python :: python conditionals 
Python :: save jupyter notebook session 
Python :: protected class python 
Python :: how to create dictionary in python 
Python :: what does enumerate do in python 
Python :: infinite while loop in python 
Python :: df mask 
Python :: python web app 
Python :: python sort list opposite 
Python :: how to while true python 
Python :: examples of function in python 
Python :: crypto trading bot python 
Python :: spliting the text to lines and keep the deliminaters python 
Python :: python request body json 
Python :: randint 
Python :: dependency injection python 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =