'Pandas: df["<tab> find completion, df.loc["<tab> WON'T find any completion. Is it normal?

I read somewhere that the preferred way for accessing dataframes columns is through the method .loc, but I found some drawbacks and I am wondering if it is normal.

Say that I do the following:

import pandas as pd
df = read_csv("MyFile.csv")

and assume that the dataframe df that looks like this:

      ColA   ColB  ColC
Time
0.0    9.2  -3.5   2.0
0.1   10.2  -0.9   1.1
0.2    4.3   2.1   4.2

If I type df[" and then hit TAB the autocompletion kicks in and I can choose the column name from a pop up list whereas if I type df.loc[" and then hit TAB, then nothing happens and I am wondering if it is a normal behavior.

Also, it seems that if the column name are tuples, e.g.

      ('ColA','X')    ('ColB','Y')    ('ColC','Z')
Time
0.0        9.2            -3.5            2.0
0.1       10.2            -0.9            1.1
0.2        4.3             2.1            4.2

then I can access them with e.g. df[('ColA','X')] but I cannot with df.loc[('ColA','X')]. I am running iPython 7.2.2 (console) on a Windows 10 machine, if it may help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source