Doubt regarding Excel manipulation through pandas library in Pycharm

Asked

Viewed 67 times

1

I have a question regarding the manipulation of Excel through the pandas library.

First I import the pandas library, then I assign to a variable the path that is the spreadsheet.

import pandas as pd
df = pd.read_excel(r'C:\Users\victo\Desktop\planilha_vendas\xlsx') # Caminho do arquivo

But once I’ve done that, I can’t use the pandas library methods, according to the image: inserir a descrição da imagem aqui

One way I found to make the methods available was after reading the path, to convert the variable to Data Frame, as follows:

import pandas as pd #importa a biblioteca
df = pd.read_excel(r'C:\Users\victo\Desktop\planilha_vendas\xlsx') #Caminho do arquivo
df = pd.DataFrame(df) #Conversão para Data Frame

In the image below, the methods are available after you have done this

inserir a descrição da imagem aqui

Well, my question is why in Pycharm the methods are only available after making this conversion in xlsx format? Because when I used google colab did not need it. The options appear right after reading the spreadsheet.

One fact I noticed when using Pycharm, is that when the format is CSV, it is not necessary to do this type of conversion. The methods are available right after reading. And this is puzzling me.

Follow the CSV image that shows the options right after reading:

import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/jennybc/gapminder/master/data-raw/04_gap-merged.tsv", sep= '\t')

inserir a descrição da imagem aqui

No answers

Browser other questions tagged

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