Python Forum

Full Version: usecols
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I want to read in two different columns, but the below does not work. How do I make it so that only columns A and L are read in? Does not contain headers.
Tfile=pd.read_excel(Node, usecols="A","L")

Figured it out pretty quickly. Just used column numbers usecols=[0,11] Why doesn't "A", and "L" work similar to using 0,11?
It's always a good idea to read documentation: pandas.read_excel:

Quote:usecols int, str, list-like, or callable default None
  • /.../
  • If str, then indicates comma separated list of Excel column letters and column ranges (e.g. “A:E” or “A,C,E:F”). Ranges are inclusive of both sides.
    /.../

So one should use "A,L" instead of "A", "L"