0
I have a pandas dataframe with five rows 3 three columns. I want to create a function where my code returns which columns the value of the last row is greater than the first row. In the example of my code I want it to generate me a list with the column name 'Temp01'. I got in the way of creating if/Else to check the columns whose last row is larger than the first. Below follows my code:
#Importa as Bibliotecas Pandas e Numpy
import pandas as pd
#Cria do Dataframe
df0 = pd.DataFrame({'Temp01':[10,20,30,40,15],'Temp02':[50,60,70,70,45],'Temp03':[80,90,100,100,75]})
#Separa Colunas cuja ultima linha seja maior que a primeira
teste =[]#Lista c o nome de cada coluna do Dataframe df0
for column in df0.columns:
#df0.column[-1] para pegar a ultima linha de cada coluna
#df0.column[0] para pegar a primeira linha de cada coluna
if df0.column[-1]> df0.column[0]:
text = column
teste.append(text)
else:
pass
print(teste)