Hi,
I have a data frame that I am trying to save as a PNG image on PythonAnywhere. For now its the same directory as the Jupyter notebook, but I will try to save it in a separate directory later. However, I am getting the OSError: read past end of file.
Not sure how to proceed with this issue.
df = pd.DataFrame('data')
dfi.export(df, 'img.png')
Error trace below :
SError Traceback (most recent call last)
<ipython-input-3-8a07a1ef9b89> in <module>
31 playermatches_df = playermatches_df[["goals", "assists", "h_team", "a_team", "date", "season", "xG", "xA", "h_goals", "a_goals", "time"]]
32 df = playermatches_df.query("h_team == @opposition or a_team == @opposition")
---> 33 dfi.export(df, 'img.png')
~/.local/lib/python3.8/site-packages/dataframe_image/_pandas_accessor.py in export(obj, filename, fontsize, max_rows, max_cols, table_conversion, chrome_path)
22 def export(obj, filename, fontsize=14, max_rows=None, max_cols=None,
23 table_conversion='chrome', chrome_path=None):
---> 24 return _export(obj, filename, fontsize, max_rows, max_cols, table_conversion, chrome_path)
25
26
~/.local/lib/python3.8/site-packages/dataframe_image/_pandas_accessor.py in _export(obj, filename, fontsize, max_rows, max_cols, table_conversion, chrome_path)
71 html = obj.to_html(max_rows=max_rows, max_cols=max_cols, notebook=True)
72
---> 73 img_str = converter(html)
74
75 if isinstance(filename, str):
~/.local/lib/python3.8/site-packages/dataframe_image/_screenshot.py in run(self, html)
165 def run(self, html):
166 self.html = self.css + html
--> 167 img = self.take_screenshot()
168 img_str = self.finalize_image(img)
169 return img_str
~/.local/lib/python3.8/site-packages/dataframe_image/_screenshot.py in take_screenshot(self)
117
118 buffer = io.BytesIO(img_bytes)
--> 119 img = mimage.imread(buffer)
120 return self.possibly_enlarge(img)
121
/usr/lib/python3.8/site-packages/matplotlib/image.py in imread(fname, format)
1434 return handler(fd)
1435 else:
-> 1436 return handler(fname)
1437
1438
/usr/lib/python3.8/site-packages/matplotlib/image.py in read_png(*args, **kwargs)
1388 def read_png(*args, **kwargs):
1389 from matplotlib import _png
-> 1390 return _png.read_png(*args, **kwargs)
1391
1392 handlers = {'png': read_png, }
OSError: read past end of file