Skip to content

Commit 75c82ec

Browse files
authored
chore: fixed to_dataframe header issue (#20)
* chore: fix to_dataframe header issue
1 parent e73ce4a commit 75c82ec

File tree

13 files changed

+278
-197
lines changed

13 files changed

+278
-197
lines changed

packages/google-cloud-documentai-toolbox/.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
* @googleapis/yoshi-python @googleapis/cdpe-cloudai
1010

1111
# @googleapis/python-samples-reviewers @googleapis/cdpe-cloudai are the default owners for samples changes
12-
# /samples/ @googleapis/python-samples-reviewers @googleapis/cdpe-cloudai
12+
/samples/ @googleapis/python-samples-reviewers @googleapis/cdpe-cloudai

packages/google-cloud-documentai-toolbox/.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Setup Python
1313
uses: actions/setup-python@v4
1414
with:
15-
python-version: "3.10"
15+
python-version: "3.9"
1616
- name: Install nox
1717
run: |
1818
python -m pip install --upgrade setuptools pip wheel
@@ -28,7 +28,7 @@ jobs:
2828
- name: Setup Python
2929
uses: actions/setup-python@v4
3030
with:
31-
python-version: "3.10"
31+
python-version: "3.9"
3232
- name: Install nox
3333
run: |
3434
python -m pip install --upgrade setuptools pip wheel

packages/google-cloud-documentai-toolbox/.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Setup Python
1313
uses: actions/setup-python@v4
1414
with:
15-
python-version: "3.10"
15+
python-version: "3.8"
1616
- name: Install nox
1717
run: |
1818
python -m pip install --upgrade setuptools pip wheel

packages/google-cloud-documentai-toolbox/.github/workflows/unittest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Setup Python
4242
uses: actions/setup-python@v4
4343
with:
44-
python-version: "3.10"
44+
python-version: "3.8"
4545
- name: Install coverage
4646
run: |
4747
python -m pip install --upgrade setuptools pip wheel

packages/google-cloud-documentai-toolbox/.kokoro/docker/docs/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ RUN apt-get update \
6060
&& rm -rf /var/lib/apt/lists/* \
6161
&& rm -f /var/cache/apt/archives/*.deb
6262

63-
###################### Install python 3.8.11
63+
###################### Install python 3.9.13
6464

65-
# Download python 3.8.11
66-
RUN wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz
65+
# Download python 3.9.13
66+
RUN wget https://www.python.org/ftp/python/3.9.13/Python-3.9.13.tgz
6767

6868
# Extract files
69-
RUN tar -xvf Python-3.8.11.tgz
69+
RUN tar -xvf Python-3.9.13.tgz
7070

71-
# Install python 3.8.11
72-
RUN ./Python-3.8.11/configure --enable-optimizations
71+
# Install python 3.9.13
72+
RUN ./Python-3.9.13/configure --enable-optimizations
7373
RUN make altinstall
7474

7575
###################### Install pip

packages/google-cloud-documentai-toolbox/.kokoro/release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
set -eo pipefail
1717

1818
# Start the releasetool reporter
19-
python3 -m pip install --require-hashes -r .kokoro/requirements.txt
19+
python3 -m pip install --require-hashes -r github/python-documentai-toolbox/.kokoro/requirements.txt
2020
python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script
2121

2222
# Disable buffering, so that the logs stream through.

packages/google-cloud-documentai-toolbox/.kokoro/requirements.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ typing-extensions
55
twine
66
wheel
77
setuptools
8-
nox
8+
nox
9+
charset-normalizer<3
10+
click<8.1.0

packages/google-cloud-documentai-toolbox/.kokoro/requirements.txt

Lines changed: 198 additions & 158 deletions
Large diffs are not rendered by default.

packages/google-cloud-documentai-toolbox/docs/_templates/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="document">
66
{{ sidebar() }}
77
{%- block document %}
8-
<div class="Document">
8+
<div class="documentwrapper">
99
{%- if render_sidebar %}
1010
<div class="bodywrapper">
1111
{%- endif %}

packages/google-cloud-documentai-toolbox/google/cloud/documentai_toolbox/wrappers/page.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,18 @@ def to_dataframe(self) -> pd.DataFrame:
5454
The DataFrame of the table.
5555
5656
"""
57-
rows = self.body_rows if self.body_rows != [] else self.header_rows
58-
59-
rows.append("\n")
60-
rows.append("\n")
61-
62-
dataframe = pd.DataFrame(rows)
63-
if self.body_rows != [] and self.header_rows != []:
64-
dataframe.columns = self.header_rows
57+
dataframe = None
58+
59+
if not self.body_rows:
60+
dataframe = pd.DataFrame(columns=self.header_rows)
61+
else:
62+
if self.header_rows != []:
63+
dataframe = pd.DataFrame(self.body_rows)
64+
dataframe.columns = self.header_rows
65+
else:
66+
67+
dataframe = pd.DataFrame(self.body_rows)
68+
dataframe.columns = [None] * len(self.body_rows[0])
6569

6670
return dataframe
6771

0 commit comments

Comments
 (0)