Create tuples of dataframe generated by Pandas

0

Is it possible to generate a tuple that stores the row values of a dataframe generated by pandas? I uploaded the values from a CSV file to a dataframe, now I need to perform some calculations with these values, but I have not found any tips on the internet. Thanks.

For example: tuple="valueA", "valueB".

Where tuple is the column name .

valueA is the value contained in the first row of this column .

valueB is the heat contained in the second line of this column .

And so on while there are lines in the dataframe .

 import pandas as pd

    df = pd.read_csv("TESTE.CSV", sep=",",header=None,usecols=[0,1,2,3,4,5,6],engine="python")

    print (df)
    
asked by anonymous 27.04.2017 / 21:27

1 answer

2

Good afternoon

You can do this:

tuples = [tuple(x) for x in df.values]

For you to get the tuples by column would look something like this:

colunas = df.columns.values
tuples = [tuple(x) for x in [df[coluna].values for coluna in colunas]]
    
27.04.2017 / 22:29