Remove row and column numbering from the Dataframe of an Array

Asked

Viewed 77 times

0

I am making a program that reads a table in CSV and transforms it into an array in python using pandas, I was able to transform it but Dataframe numbered the rows and columns and I wish to delete them. Follow the picture, what’s in red is what I want you to take out, or at least not show up.

import pandas as pd

df_cronograma=pd.read_csv('cronograma.csv', sep=';',header=None)
df_custohora=pd.read_csv('custohora.csv', sep=';',header=None)
matriz_cronograma =df_cronograma.values
matriz_custohora =df_custohora.values


df1 = pd.DataFrame(matriz_cronograma)
print(df1)
df2= pd.DataFrame(matriz_custohora)
print(df2)

inserir a descrição da imagem aqui

  • 1

    The problem is in header=None. Remove this part of your code. Hug!

1 answer

1


The horizontal numbers are showing up because you used header=None

Change to

df_cronograma=pd.read_csv('cronograma.csv', sep=';')
df_custohora=pd.read_csv('custohora.csv', sep=';')

The vertical numbers, on the other hand, are the index.

To print without the index, do:

sem_indice = df_cronograma.to_string(index=False)

print(sem_indice)
  • I got it!! Thank you very much !! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.