Sep-13-2021, 05:32 PM
Hello I would like to ask for help.
From the matrix in excel shown below
A B C D E F G
1 2 1 1 7 1 1
2 3 2 4 4 2 5
3 4 3 4 5 4 6
4 5 5 5 5 6 7
4 2 4 6 5 5 8
I want to extract the numeric values from columns A, C and E to form a matrix like the one shown below.
1 1 7
2 2 4
3 3 5
4 5 5
4 4 5
However, I want to do it, through this interface that I have developed in Tkinter by pressing the buttons A, C and E.
Currently I have programmed in such a way that when pressing the buttons, the columns are extracted from the file in excel, as shown below.
note: I would like to design in such a way as to build the matrix grouping any column of the excel file for example A, B and C or D, F and G
Previously I have managed to form the matrix by extracting the numerical values from columns A, C and E using the following code
import pandas as pd
datos= pd.read_excel('proyecto matriz.xlsx')
df=pd.DataFrame(datos, columns=["A" ,"B","D"])
matriz=df.values.tolist()
print(matriz)
From the matrix in excel shown below
A B C D E F G
1 2 1 1 7 1 1
2 3 2 4 4 2 5
3 4 3 4 5 4 6
4 5 5 5 5 6 7
4 2 4 6 5 5 8
I want to extract the numeric values from columns A, C and E to form a matrix like the one shown below.
1 1 7
2 2 4
3 3 5
4 5 5
4 4 5
However, I want to do it, through this interface that I have developed in Tkinter by pressing the buttons A, C and E.
Currently I have programmed in such a way that when pressing the buttons, the columns are extracted from the file in excel, as shown below.
from tkinter import* ventana=Tk() ventana.geometry("600x600") ventana.title("Prueba") def A(): import pandas as pd datos= pd.read_excel('proyecto matriz.xlsx') print(datos.iloc[:,0:1]) def B(): import pandas as pd datos= pd.read_excel('proyecto matriz.xlsx') print(datos.iloc[:,1:2]) def C(): import pandas as pd datos= pd.read_excel('proyecto matriz.xlsx') print(datos.iloc[:,2:3]) def D(): import pandas as pd datos= pd.read_excel('proyecto matriz.xlsx') print(datos.iloc[:,3:4]) def E(): import pandas as pd datos= pd.read_excel('proyecto matriz.xlsx') print(datos.iloc[:,4:5]) def F(): import pandas as pd datos= pd.read_excel('proyecto matriz.xlsx') print(datos.iloc[:,5:6]) def G(): import pandas as pd datos= pd.read_excel('proyecto matriz.xlsx') print(datos.iloc[:,6:7]) botonA=Button(text="A",command=A).pack() botonB=Button(text="B",command=B).pack() botonC=Button(text="C",command=C).pack() botonD=Button(text="D",command=D).pack() botonE=Button(text="E",command=E).pack() botonF=Button(text="F",command=F).pack() botonG=Button(text="G",command=G).pack()However, I want to form a matrix with only the numerical values, how can I do it?
note: I would like to design in such a way as to build the matrix grouping any column of the excel file for example A, B and C or D, F and G
Previously I have managed to form the matrix by extracting the numerical values from columns A, C and E using the following code
import pandas as pd
datos= pd.read_excel('proyecto matriz.xlsx')
df=pd.DataFrame(datos, columns=["A" ,"B","D"])
matriz=df.values.tolist()
print(matriz)