0
Hello, all right?
You can do as follows, see this example below:
import pandas as pd
data = [[1,2,3],[3,4,5], [5,6,7], [7,8,9]]
col = ['col_'+str(i) for i in range(len(data[0]))]
row = ['row_'+str(i) for i in range(len(data))]
df = pd.DataFrame(data, columns = col)
df.index = row
df
Result of dataframe df
Hence, you can select part of this dataframe using the iloc
, for example:
# df.iloc[seleciona linhas, seleciona colunas]
df2 = df.iloc[1:4,1:]
df2
Result of dataframe df2
And then transposed the dataframe df2
is just to do,
df2_T = df2.T
df2_T
Date frame transpose result df2
Dataframe and this method
iloc
are from Pandas, right?! It would be better to add the tag [tag:pandas] in the question to facilitate the search.– fernandosavio
But what you want to do is not the
transposta
ofdf
original? if your representation is wrong, the transposition of thedf
orginal Teri that have only 2 lines and not 3.– Sidon