conflict with PyPDF2?
I am not sure if it is a bug of pandas or mine.
but when I test my code I have the following peculiar error: **an error that disappears if I run again the exact same line of code of pandas**
After I successfully ran my code, I try the following block of code
```
import pandas as pd
df = pd.DataFrame([['a', 'b', 'c'], ['d', '6', '8']])
df[df.apply(lambda x: x.str.contains('e')).any()]
```
and it hit an error, strange is that the code block behaves as expected if I try it again after it hit the error, see below
```
~/Documents/cs_project/toc(master*) » python3 -i corp_gov_report.py                                                                                                     macone@Macs-MacBook-Pro
Bounding box (Decimal('124.724'), Decimal('46.220'), Decimal('752.754'), Decimal('753.770')) is not fully within parent page bounding box (Decimal('0'), Decimal('0'), Decimal('595.276'), Decimal('807.874'))
Bounding box (Decimal('124.724'), Decimal('46.220'), Decimal('752.754'), Decimal('753.770')) is not fully within parent page bounding box (Decimal('0'), Decimal('0'), Decimal('595.276'), Decimal('807.874'))
currency                                   HK$’000
5         Audit and audit related services   1,800
8                     financial statements     600
Independent Auditor’s Remuneration (iv)  獨立核數師之酬金
During the year, the remuneration paid or payable to the  於本年度，已付或應付予獨立核數師安
independent auditor, Ernst & Young, is set out as follows: 永會計師事務所之酬金載列如下：
Services rendered HK$’000
所提供服務 千港元
     
Audit and audit related services 審核及審核相關服務 1,800
Non-audit services 非審核服務
Review of interim condensed consolidated  審閱中期簡明綜合財務報告
financial statements 600
Tax advisory services 稅務諮詢服務 113
>>> df = pd.DataFrame([['a', 'b', 'c'], ['d', '6', '8']])
>>> df[df.apply(lambda x: x.str.contains('e')).any()]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py", line 2890, in __getitem__
    return self._getitem_bool_array(key)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py", line 2933, in _getitem_bool_array
    stacklevel=3,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/warnings.py", line 110, in _showwarnmsg
    msg.file, msg.line)
  File "/Users/macone/Library/Python/3.7/lib/python/site-packages/PyPDF2/pdf.py", line 1069, in _showwarning
    file.write(formatWarning(message, category, filename, lineno, line))
  File "/Users/macone/Library/Python/3.7/lib/python/site-packages/PyPDF2/utils.py", line 69, in formatWarning
    file = filename.replace("/", "\\").rsplit("\\", 1)[1] # find the file name
IndexError: list index out of range
>>> df[df.apply(lambda x: x.str.contains('e')).any()]
Empty DataFrame
Columns: [0, 1, 2]
Index: []
```
but if i ran `df[df.apply(lambda x: x.str.contains('e')).any()]` again, the error appear again, but if i trid again, it disappear
```
>>> df[df.apply(lambda x: x.str.contains('e')).any()]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py", line 2890, in __getitem__
    return self._getitem_bool_array(key)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py", line 2933, in _getitem_bool_array
    stacklevel=3,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/warnings.py", line 110, in _showwarnmsg
    msg.file, msg.line)
  File "/Users/macone/Library/Python/3.7/lib/python/site-packages/PyPDF2/pdf.py", line 1069, in _showwarning
    file.write(formatWarning(message, category, filename, lineno, line))
  File "/Users/macone/Library/Python/3.7/lib/python/site-packages/PyPDF2/utils.py", line 69, in formatWarning
    file = filename.replace("/", "\\").rsplit("\\", 1)[1] # find the file name
IndexError: list index out of range
>>> df[df.apply(lambda x: x.str.contains('e')).any()]
Empty DataFrame
Columns: [0, 1, 2]
Index: []
>>> df[df.apply(lambda x: x.str.contains('e')).any()]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py", line 2890, in __getitem__
    return self._getitem_bool_array(key)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py", line 2933, in _getitem_bool_array
    stacklevel=3,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/warnings.py", line 110, in _showwarnmsg
    msg.file, msg.line)
  File "/Users/macone/Library/Python/3.7/lib/python/site-packages/PyPDF2/pdf.py", line 1069, in _showwarning
    file.write(formatWarning(message, category, filename, lineno, line))
  File "/Users/macone/Library/Python/3.7/lib/python/site-packages/PyPDF2/utils.py", line 69, in formatWarning
    file = filename.replace("/", "\\").rsplit("\\", 1)[1] # find the file name
IndexError: list index out of range
>>> df[df.apply(lambda x: x.str.contains('e')).any()]
Empty DataFrame
Columns: [0, 1, 2]
Index: []
>>> df[df.apply(lambda x: x.str.contains('e')).any()]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
```
see here for the image:
![image](https://user-images.githubusercontent.com/51902242/95024823-25a12900-06b8-11eb-9762-8a50212d73e8.png)

In addition, I encounter this error when I was trying to do this during the project development.
```
    @property
    def df_clean_table(self):
        df_filtered_table = self.df_filtered_table
        currency_cols = self.get_cond_cols(df_filtered_table, self.currency_element)
        financial_num_cols = self.get_cond_cols(df_filtered_table, self.financial_num_element)
        currency_rows= self.get_cond_rows(df_filtered_table, self.currency_element)
        year_rows = self.get_cond_rows(df_filtered_table, self.year_element)


        currency_row_idx = df_filtered_table.loc[currency_rows, financial_num_cols].index
        currency_row = df_filtered_table.loc[currency_row_idx]
        currency_header = currency_row[currency_row.apply(self.currency_element, axis=1)].fillna('').values.flatten()
        
        year_row_idx = df_filtered_table.loc[year_rows, currency_cols].index
        year_row = df_filtered_table.loc[year_row_idx]
        year_header = year_row[year_row.apply(self.year_element, axis=1)].fillna('').values.flatten()

        if year_header:
            df_filtered_table.columns = pd.MultiIndex.from_arrays([year_header, currency_header], names = ['year', 'currency'])
        else:
            df_filtered_table.columns = pd.MultiIndex.from_arrays([currency_header], names=['currency'])
        return df_filtered_table.drop(year_row_idx.append(currency_row_idx))
```
see below
![image](https://user-images.githubusercontent.com/51902242/95023884-246cfd80-06b2-11eb-883e-f2ae57ebf512.png)

but where I was debugging, I tried:
```
df_filtered_table = table.df_filtered_table
year_rows = table.get_cond_rows(df_filtered_table, table.year_element)
currency_cols = table.get_cond_cols(df_filtered_table, table.currency_element)
year_row_idx = df_filtered_table.loc[year_rows, currency_cols].index
year_row = df_filtered_table.loc[year_row_idx]
year_header = year_row[year_row.apply(table.year_element, axis=1)].fillna('').values.flatten()
if not year_header:
    print('here is the error!')

if not year_header:
    print('here no the error!')

```
see below:
![image](https://user-images.githubusercontent.com/51902242/95024258-79117800-06b4-11eb-89cf-99ba4deb4bc1.png)

here is the full error and the debugging..
```
~/Documents/cs_project/toc(master*) » python3 -i corp_gov_report.py                                                                                                     macone@Macs-MacBook-Pro
Bounding box (Decimal('124.724'), Decimal('46.220'), Decimal('752.754'), Decimal('753.770')) is not fully within parent page bounding box (Decimal('0'), Decimal('0'), Decimal('595.276'), Decimal('807.874'))
Bounding box (Decimal('124.724'), Decimal('46.220'), Decimal('752.754'), Decimal('753.770')) is not fully within parent page bounding box (Decimal('0'), Decimal('0'), Decimal('595.276'), Decimal('807.874'))
Traceback (most recent call last):
  File "corp_gov_report.py", line 161, in <module>
    print(table.df_clean_table)
  File "corp_gov_report.py", line 128, in df_clean_table
    if year_header:
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/warnings.py", line 110, in _showwarnmsg
    msg.file, msg.line)
  File "/Users/macone/Library/Python/3.7/lib/python/site-packages/PyPDF2/pdf.py", line 1069, in _showwarning
    file.write(formatWarning(message, category, filename, lineno, line))
  File "/Users/macone/Library/Python/3.7/lib/python/site-packages/PyPDF2/utils.py", line 69, in formatWarning
    file = filename.replace("/", "\\").rsplit("\\", 1)[1] # find the file name
IndexError: list index out of range
>>> df_filtered_table = table.df_filtered_table
year_rows = table.get_cond_rows(df_filtered_table, table.year_element)
currency_cols = table.get_cond_cols(df_filtered_table, table.currency_element)
year_row_idx = df_filtered_table.loc[year_rows, currency>>> year_rows = table.get_cond_rows(df_filtered_table, table.year_element)
currency_cols = table.get_cond_cols(df_filtered_table, table.currency_element)
year_row_idx = df_filtered_table.loc[year_rows, currency_cols].index
year_row = df_filtered_table.loc[year_row_idx]
year_header = year_row[year_row.apply(ta>>> currency_cols = table.get_cond_cols(df_filtered_table, table.currency_element)
year_row_idx = df_filtered_table.loc[year_rows, currency_cols].index
year_row = df_filtered_table.loc[year_row_idx]
year_header = year_row[year_row.apply(table.year_element, axis=1)].fillna('').values.flatt>>> year_row_idx = df_filtered_table.loc[year_rows, currency_cols].index
>>> year_row = df_filtered_table.loc[year_row_idx]
>>> year_header = year_row[year_row.apply(table.year_element, axis=1)].fillna('').values.flatten()
if not year_header:
    print('here is the error!')

if not year_header:
    print('here no the>>> if not year_header:
...     print('here is the error!')
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/warnings.py", line 110, in _showwarnmsg
    msg.file, msg.line)
  File "/Users/macone/Library/Python/3.7/lib/python/site-packages/PyPDF2/pdf.py", line 1069, in _showwarning
    file.write(formatWarning(message, category, filename, lineno, line))
  File "/Users/macone/Library/Python/3.7/lib/python/site-packages/PyPDF2/utils.py", line 69, in formatWarning
    file = filename.replace("/", "\\").rsplit("\\", 1)[1] # find the file name
IndexError: list index out of range
>>> if not year_header:
...     print('here no the error!')
... 
here no the error!
```
you may see the error disappears when I try again to check the if-clause:`if not year_header`. 

Here is the error message

```
Traceback (most recent call last):
  File "corp_gov_report.py", line 161, in <module>
    print(table.df_clean_table)
  File "corp_gov_report.py", line 128, in df_clean_table
    if year_header:
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/warnings.py", line 110, in _showwarnmsg
    msg.file, msg.line)
  File "/Users/macone/Library/Python/3.7/lib/python/site-packages/PyPDF2/pdf.py", line 1069, in _showwarning
    file.write(formatWarning(message, category, filename, lineno, line))
  File "/Users/macone/Library/Python/3.7/lib/python/site-packages/PyPDF2/utils.py", line 69, in formatWarning
    file = filename.replace("/", "\\").rsplit("\\", 1)[1] # find the file name
IndexError: list index out of range
```

The error message is very similar to the replicated example I showed at the beginning, except the following lines.

```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py", line 2890, in __getitem__
    return self._getitem_bool_array(key)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/frame.py", line 2933, in _getitem_bool_array
    stacklevel=3,
```

If any worth, the following is my developing project, you may see the full project in this [repo](https://github.com/fdq09eca/cs-project/tree/master/toc) (the file hitting the error is `corp_gov_report.py` and its content is shown as below)

```
from pdf import PDF, Outline, ReportOutline, PageWithSection
from helper import flatten
import datetime
import re
import pandas as pd


class CorporateGovReport(ReportOutline):

    title_regex = r'^(?=.*report).*corporate governance.*$'

    def __init__(self, outline):
        super().__init__(outline)

    @property
    def audit_fee(self):
        return AuditFee.retrieve(self.pages)


class AuditFee(PageWithSection):

    section_regex = r"^(?!.*Nomination|.*Report)(?=.*REMUNERATION|.*independent|.*external|.*Accountability).*auditor.*$"

    def __init__(self, pages):
        super().__init__(pages)

    @property
    def sections(self):
        return flatten([page.get_section(AuditFee.section_regex) for page in self.pages])

    @property
    def tables(self):
        return [AuditFeeTable.retrieve(section) for section in self.sections]


class AuditFeeTable:
    setting = {
        "vertical_strategy": "text",
        "horizontal_strategy": "text"
    }

    currency_regex = 'HK'
    financial_num_regex = '\d,?\d*'
    year_regex = '|'.join(map(str, range(int(datetime.datetime.now().year) - 2, int(datetime.datetime.now().year) + 1)))

    def __init__(self, section):
        self.section = section

    @classmethod
    def retrieve(cls, section):
        return cls(section.page)

    @classmethod
    def set_year_regex(cls, current_year: int):
        cls.year_regex = '|'.join(
            map(str, range(current_year - 2, current_year + 1)))
        print(f'Set {cls.__name__}.year_regex to {cls.year_regex}')

    @property
    def raw_table(self):
        return self.section.extract_table(AuditFeeTable.setting)

    @property
    def df_raw_table(self):
        df = pd.DataFrame(self.raw_table)
        return df

    @staticmethod
    def currency_element(x):
        return x.str.contains(AuditFeeTable.currency_regex)

    @staticmethod
    def financial_num_element(x):
        return x.str.contains(AuditFeeTable.financial_num_regex)

    @staticmethod
    def year_element(x):
        return x.str.contains(AuditFeeTable.year_regex)
    
    @staticmethod
    def eng_element(x):
        return x.str.contains(r'[A-Za-z0-9]+')
    
    @staticmethod
    def get_cond_cols(df, element_cond_func):
        return df.apply(element_cond_func).any()
    
    @staticmethod
    def get_cond_rows(df, element_cond_func):
        return df.apply(element_cond_func).any(axis=1)
    
    @property
    def df_fee(self):
        df = self.df_raw_table
        currency_cols = self.get_cond_cols(df, self.currency_element)
        currency_rows = self.get_cond_rows(df, self.currency_element)
        financial_num_rows = self.get_cond_rows(df, self.financial_num_element)
        year_rows = self.get_cond_rows(df, self.year_element)
        df_fee = df.loc[(financial_num_rows|year_rows) , currency_cols]
        return df_fee

   
    @property
    def df_filtered_table(self):
        df_fee = self.df_fee
        df_filtered_table = self.df_raw_table.iloc[df_fee.index]
        df_filtered_table = df_filtered_table.loc[:, self.get_cond_cols(df_filtered_table, self.eng_element)]
        return df_filtered_table
    
    
    @property
    def df_clean_table(self):
        df_filtered_table = self.df_filtered_table
        currency_cols = self.get_cond_cols(df_filtered_table, self.currency_element)
        financial_num_cols = self.get_cond_cols(df_filtered_table, self.financial_num_element)
        currency_rows= self.get_cond_rows(df_filtered_table, self.currency_element)
        year_rows = self.get_cond_rows(df_filtered_table, self.year_element)


        currency_row_idx = df_filtered_table.loc[currency_rows, financial_num_cols].index
        currency_row = df_filtered_table.loc[currency_row_idx]
        currency_header = currency_row[currency_row.apply(self.currency_element, axis=1)].fillna('')
        
        year_row_idx = df_filtered_table.loc[year_rows, currency_cols].index
        year_row = df_filtered_table.loc[year_row_idx]
        year_header = year_row[year_row.apply(self.year_element, axis=1)].fillna('')

        if not year_header.empty and not currency_header.enpty:
            df_filtered_table.columns = pd.MultiIndex.from_arrays([year_header.iloc[0], currency_header.iloc[0]], names = ['year', 'currency'])
        else:
            df_filtered_table.columns = pd.MultiIndex.from_arrays([currency_header.iloc[0]], names=['currency'])
        return df_filtered_table.drop(year_row_idx.append(currency_row_idx))


    @property
    def currency(self):
        pass

    @property
    def currency_unit(self):
        pass

    @property
    def total(self):
        pass

    def __repr__(self):
        return f'{self.__class__.__name__} - {self.section}'


if __name__ == '__main__':
    url, p = 'https://www1.hkexnews.hk/listedco/listconews/sehk/2020/0721/2020072100713.pdf', 61
    # url, p = 'https://www1.hkexnews.hk/listedco/listconews/sehk/2020/0721/2020072100653.pdf', 94
    pdf = PDF.create(url)

    corp_gov_report = pdf.get_outline(CorporateGovReport.title_regex)
    corp_gov_report = CorporateGovReport.create(corp_gov_report[0])
    page = corp_gov_report.audit_fee.pages[0]
    sec = corp_gov_report.audit_fee.sections[0]
    table = corp_gov_report.audit_fee.tables[0]
    print(table.df_clean_table)
    print(sec.text)
    # print(corp_gov_report.pages)

    # page = pdf.
```
here are the dependencies 
```
~/Documents/cs_project/toc(master*) » pip3 freeze 
chardet==3.0.4
numpy==1.19.1
pandas==1.1.0
pdfminer.six==20200517
pdfplumber==0.5.23
Pillow==7.2.0
pycryptodome==3.9.8
PyPDF2==1.26.0
python-dateutil==2.8.1
pytz==2020.1
six==1.15.0
sortedcontainers==2.2.2
Wand==0.6.2
```