Barzi2001
Barzi2001

Reputation: 1766

Spyder: how to show only dataframe columns when hitting the tab key?

I am switching from Matlab to Python and I am facing the first hurdles. :)

I have the following code:

import pandas as pd
T = pd.read_csv("MyFile.csv", sep=';')

So far, so good, but I have two problems:

  1. In the console: when I type T. and then I hit TAB, I get listed all the columns of the dataframe along with all the possible commands that I can perform on T. How should I do to get listed only the dataframe columns?
  2. In the editor: when I type T. followed by TAB, it takes long time before I see anything listed.

I wish the following behavior: when I type T. and then I hit TAB (or some other key) I shall get listed only the columns of the dataframe that I can then select by using the arrow keys on my keyboard.

I am running on Windows 10 with Spyder 5.1.5 installed through Anaconda and I also have jedi installed (but I don't know if it is active though, but on the bottom of Spyder I can see LSP Python: ready).

Upvotes: 1

Views: 750

Answers (1)

Abhyuday Vaish
Abhyuday Vaish

Reputation: 2379

I guess you need Column names. Here's how:

print(list(T.columns.values))

Or simply:

print(list(T))

Also, till now there might be no way to get column names with arrow keys or any other key.

I don't exactly know what could be the reason for your second question. You can take a look at this. Even though it's about MacOS but it might help.

Upvotes: 1

Related Questions