Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
usecols
#1
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?
Reply
#2
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"
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020