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

Dataframe_image v0.2.22 cannot save to BytesIO buffer, but v0.1.11 can. #108

Closed
rahulraj80 opened this issue Dec 1, 2023 · 0 comments
Closed

Comments

@rahulraj80
Copy link

Minimal code to reproduce the error:

v0.2.22 :

import pandas as pd
from io import BytesIO
import dataframe_image as dfi
df = pd.DataFrame({'num_legs': [2, 4, 8, 0],
                    'num_wings': [2, 0, 0, 0],
                    'num_specimen_seen': [10, 2, 1, 8]},
                   index=['falcon', 'dog', 'spider', 'fish'])
buf = BytesIO()
df.dfi.export(buf, table_conversion='matplotlib')

Error :

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-2-fa5a6a1b0f2e>](https://localhost:8080/#) in <cell line: 9>()
      7                    index=['falcon', 'dog', 'spider', 'fish'])
      8 buf = BytesIO()
----> 9 df.dfi.export(buf, table_conversion='matplotlib')

4 frames
[/usr/local/lib/python3.10/dist-packages/dataframe_image/_pandas_accessor.py](https://localhost:8080/#) in export(self, filename, fontsize, max_rows, max_cols, table_conversion, chrome_path, dpi)
     33         dpi=None,
     34     ):
---> 35         return export(
     36             self._df,
     37             filename,

[/usr/local/lib/python3.10/dist-packages/dataframe_image/_pandas_accessor.py](https://localhost:8080/#) in export(obj, filename, fontsize, max_rows, max_cols, table_conversion, chrome_path, dpi, use_mathjax)
     83 
     84         # get extension from filename without dot
---> 85         extension = Path(filename).suffix
     86         if extension.startswith("."):
     87             extension = extension[1:]

[/usr/lib/python3.10/pathlib.py](https://localhost:8080/#) in __new__(cls, *args, **kwargs)
    958         if cls is Path:
    959             cls = WindowsPath if os.name == 'nt' else PosixPath
--> 960         self = cls._from_parts(args)
    961         if not self._flavour.is_supported:
    962             raise NotImplementedError("cannot instantiate %r on your system"

[/usr/lib/python3.10/pathlib.py](https://localhost:8080/#) in _from_parts(cls, args)
    592         # right flavour.
    593         self = object.__new__(cls)
--> 594         drv, root, parts = self._parse_args(args)
    595         self._drv = drv
    596         self._root = root

[/usr/lib/python3.10/pathlib.py](https://localhost:8080/#) in _parse_args(cls, args)
    576                 parts += a._parts
    577             else:
--> 578                 a = os.fspath(a)
    579                 if isinstance(a, str):
    580                     # Force-cast str subclasses to str (issue #21127)

TypeError: expected str, bytes or os.PathLike object, not BytesIO

No errors on v0.1.11

Google Colab notebook for the test

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

1 participant