It's like how to read certain columns from Excel using Pandas - Python but a little bit more complicated.
Say I have an Excel file called "foo.xlsx" and it grows over time - a new column will be appended on the right every month. However, when I read it, I need only the first two and the last columns. I expected usecols
parameter can solve this problem so I went df = pd.read_excel("foo.xlsx", usecols=[0, 1, -1])
but it gives me only the first two columns.
My workaround turns out to be:
df = pd.read_excel("foo.xlsx")
df = df[df.columns[[0, 1, -1]]]
But it needs reading the whole file every time. Is there any way that I can get my desired data frame while reading the file? Thanks.