Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index error #112

Closed
under-score opened this issue Jan 9, 2022 · 3 comments
Closed

index error #112

under-score opened this issue Jan 9, 2022 · 3 comments

Comments

@under-score
Copy link

under-score commented Jan 9, 2022

Traceback (most recent call last):

  File "/Users/user/Documents/Daten/Projekte/Scripts/opencv_v2/my.py", line 85, in <module>
    pdflayout, images = lp.load_pdf(os.path.join(dir, fn), load_images=True, dpi=300)

  File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/layoutparser/io/pdf.py", line 182, in load_pdf
    page_tokens = extract_words_for_page(

  File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/layoutparser/io/pdf.py", line 57, in extract_words_for_page
    df[["x0", "x1"]].clip(lower=0, upper=int(page.width)).astype("float")

  File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/pandas/core/frame.py", line 3464, in __getitem__
    indexer = self.loc._get_listlike_indexer(key, axis=1)[1]

  File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexing.py", line 1314, in _get_listlike_indexer
    self._validate_read_indexer(keyarr, indexer, axis)

  File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/pandas/core/indexing.py", line 1374, in _validate_read_indexer
    raise KeyError(f"None of [{key}] are in the [{axis_name}]")

KeyError: "None of [Index(['x0', 'x1'], dtype='object')] are in the [columns]"

Is there also a space in the column index?

@lolipopshock
Copy link
Member

Interesting -- would you mind helping me check if there's an empty page in the input PDF document? Thanks!

@under-score
Copy link
Author

sorry, it's gone, but can't remember any PDF with a blank page

@lolipopshock
Copy link
Member

I suspect it's caused by empty PDF pages, which I should fix in the next few updates. I'll close this issue for now but feel free to reopen it and when you can get that PDF and take a look at it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants