Open dlohmeier opened 6 months ago
I assume that the reason behind this is that we pass the pandapower to_serializable handler as default_handler to pandas upon serialization, but we can't hand over a registry or decode-hook upon de-serialization. Is that correct? Do you have any idea of how to overcome this problem?
I think it is possible to register new handler. But you have to write one. I don't know how the impact is on loading times and co. I think the same is true for the geometry column, since this is handled by a custom loading hook.
@dlohmeier
Bug report checklis
[X] Searched the issues page for similar reports
[X] Read the relevant sections of the documentation
[X] Browse the tutorials and tests for usefull code snippets and examples of use
[X] Reproduced the issue after updating with
pip install --upgrade pandapower
(orgit pull
)[X] Tried basic troubleshooting (if a bug/error) like restarting the interpreter and checking the pythonpath
Reproducible Example
Issue Description and Traceback
When running the above code, the shapely data is transferred into the internal pandapower serialization format. Upon deserialization, this format cannot be converted back, but is kept as a dict with multiple "useless" entries, such as "_module" or "_class". I assume that the reason behind this is that we pass the pandapower _toserializable handler as default_handler to pandas upon serialization, but we can't hand over a registry or decode-hook upon de-serialization. Is that correct? Do you have any idea of how to overcome this problem? I know that serializing a dataframe is not a good usecase for the
pandapower.to_json
function, but in some cases, I do store shapely data inside my net dataframes without making them geopandas dataframes. Additionally, I sometimes use more than just one column with geodata. For such cases, I added the geopandas part of the code. It is completely impossibly to encode GeoDataFrames that contain more geodata than just that inside the "geometry" column, as the following error occurs:Expected Behavior
It would be great to retrieve shapely data even from withtin dataframes or geodataframes outside the geometry column. Any ideas on that?
Installed Versions
INSTALLED VERSIONS
commit : 2e218d10984e9919f0296931d92ea851c6a6faf5 python : 3.11.9.final.0 python-bits : 64 OS : Linux OS-release : 6.5.0-35-generic Version : #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 7 09:00:52 UTC 2 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : de_DE.UTF-8 LOCALE : de_DE.UTF-8 pandas : 1.5.3 numpy : 1.23.5 pytz : 2024.1 dateutil : 2.9.0.post0 setuptools : 70.0.0 pip : 24.0 Cython : 3.0.9 pytest : 8.1.1 hypothesis : 6.82.7 sphinx : None blosc : None feather : None xlsxwriter : 3.2.0 lxml.etree : None html5lib : None pymysql : None psycopg2 : 2.9.9 jinja2 : 3.1.3 IPython : 8.23.0 pandas_datareader: None bs4 : 4.12.3 bottleneck : None brotli : 1.1.0 fastparquet : None fsspec : None gcsfs : None matplotlib : 3.6.3 numba : 0.59.1 numexpr : None odfpy : None openpyxl : 3.1.2 pandas_gbq : None pyarrow : 15.0.2 pyreadstat : None pyxlsb : None s3fs : None scipy : 1.12.0 snappy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : 2.0.1 xlwt : None zstandard : None tzdata : 2024.1
Label