pyhdf5-handler 0.8__tar.gz → 0.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/.spyproject/config/backups/workspace.ini.bak +1 -1
  2. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/.spyproject/config/workspace.ini +1 -1
  3. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/PKG-INFO +1 -1
  4. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/Release_note.txt +3 -0
  5. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/pyhdf5_handler/src/hdf5_handler.py +9 -1
  6. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/pyhdf5_handler/tutorial/hdf5_io_tests.py +30 -0
  7. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/pyproject.toml +1 -1
  8. pyhdf5_handler-0.9/test.hdf5 +0 -0
  9. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/.spyproject/config/backups/codestyle.ini.bak +0 -0
  10. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/.spyproject/config/backups/encoding.ini.bak +0 -0
  11. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/.spyproject/config/backups/vcs.ini.bak +0 -0
  12. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/.spyproject/config/codestyle.ini +0 -0
  13. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini +0 -0
  14. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/.spyproject/config/defaults/defaults-encoding-0.2.0.ini +0 -0
  15. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/.spyproject/config/defaults/defaults-vcs-0.2.0.ini +0 -0
  16. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/.spyproject/config/defaults/defaults-workspace-0.2.0.ini +0 -0
  17. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/.spyproject/config/encoding.ini +0 -0
  18. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/.spyproject/config/vcs.ini +0 -0
  19. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/LICENSE +0 -0
  20. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/README.md +0 -0
  21. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/mycontrol.hdf5 +0 -0
  22. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/pyhdf5_handler/__init__.py +0 -0
  23. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/pyhdf5_handler/src/__init__.py +0 -0
  24. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/pyhdf5_handler/src/constant.py +0 -0
  25. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/pyhdf5_handler/src/object_handler.py +0 -0
  26. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/pyhdf5_handler/tutorial/__init__.py +0 -0
  27. {pyhdf5_handler-0.8 → pyhdf5_handler-0.9}/pyhdf5_handler/tutorial/complementary_test.py +0 -0
@@ -4,7 +4,7 @@ save_data_on_exit = True
4
4
  save_history = True
5
5
  save_non_project_files = False
6
6
  project_type = 'empty-project-type'
7
- recent_files = ['pyhdf5_handler/src/hdf5_handler.py', 'pyhdf5_handler/src/object_handler.py', 'pyhdf5_handler/tutorial/hdf5_io_tests.py', 'pyhdf5_handler/tutorial/complementary_test.py', 'test_fichier_julie.py']
7
+ recent_files = ['pyhdf5_handler/src/hdf5_handler.py', 'pyhdf5_handler/src/object_handler.py', 'pyhdf5_handler/tutorial/hdf5_io_tests.py', 'pyhdf5_handler/tutorial/complementary_test.py']
8
8
 
9
9
  [main]
10
10
  version = 0.2.0
@@ -4,7 +4,7 @@ save_data_on_exit = True
4
4
  save_history = True
5
5
  save_non_project_files = False
6
6
  project_type = 'empty-project-type'
7
- recent_files = ['pyhdf5_handler/src/hdf5_handler.py', 'pyhdf5_handler/src/object_handler.py', 'pyhdf5_handler/tutorial/hdf5_io_tests.py', 'pyhdf5_handler/tutorial/complementary_test.py', 'test_fichier_julie.py']
7
+ recent_files = ['pyhdf5_handler/src/hdf5_handler.py', 'pyhdf5_handler/src/object_handler.py', 'pyhdf5_handler/tutorial/hdf5_io_tests.py', 'pyhdf5_handler/tutorial/complementary_test.py']
8
8
 
9
9
  [main]
10
10
  version = 0.2.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyhdf5_handler
3
- Version: 0.8
3
+ Version: 0.9
4
4
  Summary: A Python library to read and write data to HDF5 format. This library is based on the h5py (https://docs.h5py.org/en/stable/index.html) and has been developed by Maxime Jay-Allemand at Hydris hydrologie (https://www.hydris-hydrologie.fr/)
5
5
  Project-URL: Homepage, https://codeberg.org/maximejay/pyhdf5_handler
6
6
  Project-URL: Issues, https://codeberg.org/maximejay/pyhdf5_handler/issues
@@ -1,3 +1,6 @@
1
+ v0.9 : 23-07-2026
2
+ - fix: handle dtype with panda dataframe: read/write
3
+
1
4
  v0.8 : 19-06-2026
2
5
  - relase 0.8
3
6
  - Add support for pd.DataFrame()
@@ -416,6 +416,13 @@ def _hdf5_handle_PandaDataFrame(
416
416
  dataset = _hdf5_handle_array("array", value.to_numpy())
417
417
  _hdf5_create_dataset(hdf5_data, dataset)
418
418
 
419
+ dtype = []
420
+ for col in value.columns:
421
+ dtype.append(value[col].dtype.name)
422
+
423
+ dataset = _hdf5_handle_list("dtype", dtype)
424
+ _hdf5_create_dataset(hdf5_data, dataset)
425
+
419
426
  return
420
427
 
421
428
 
@@ -658,10 +665,11 @@ def _read_pd_dataframe(hdf5):
658
665
  if "pd_DataFrame" in list(hdf5.keys()):
659
666
  columns = hdf5["pd_DataFrame/columns"][:]
660
667
  array = hdf5["pd_DataFrame/array"][:]
668
+ dtype = hdf5["pd_DataFrame/dtype"][:]
661
669
 
662
670
  newdict = {}
663
671
  for i, col in enumerate(columns):
664
- newdict.update({col.decode(): array[:, i]})
672
+ newdict.update({col.decode(): array[:, i].astype(dtype[i])})
665
673
 
666
674
  return pd.DataFrame(newdict)
667
675
 
@@ -74,6 +74,21 @@ if __name__ == "__main__":
74
74
  {"column1": np.array([1, 2, 3]), "column2": np.array([4, 5, 6])}
75
75
  ),
76
76
  )
77
+ pyhdf5_handler.hdf5_dataset_creator(
78
+ hdf5,
79
+ "mix_dtype_panda_dataframe",
80
+ pd.DataFrame(
81
+ {
82
+ "column1": np.array(["A", "B", "C"]),
83
+ "column2": np.array([4, 5, 6]),
84
+ }
85
+ ),
86
+ )
87
+ pyhdf5_handler.hdf5_dataset_creator(
88
+ hdf5,
89
+ "empty_dataframe",
90
+ pd.DataFrame({}),
91
+ )
77
92
 
78
93
  # write a python dictionary in the hdf5 database
79
94
  dictionary = {
@@ -86,6 +101,12 @@ if __name__ == "__main__":
86
101
  "array": np.array([1, 2, 3, 4]),
87
102
  "date_range": pd.date_range(start="1/1/2018", end="1/08/2018"),
88
103
  "list_mixte": [1.0, np.datetime64("2019-09-22 17:38:30")],
104
+ "pandas_df": pd.DataFrame(
105
+ {
106
+ "column1": np.array([1, 2, 3]),
107
+ "column2": np.array([4, 5, 6]),
108
+ }
109
+ ),
89
110
  }
90
111
  }
91
112
 
@@ -130,6 +151,10 @@ if __name__ == "__main__":
130
151
  hdf5_instance=hdf5,
131
152
  location="./panda_dataframe",
132
153
  )
154
+ pyhdf5_handler.get_hdf5_item(
155
+ hdf5_instance=hdf5,
156
+ location="./mix_dtype_panda_dataframe",
157
+ )
133
158
  pyhdf5_handler.get_hdf5_item(
134
159
  hdf5_instance=hdf5,
135
160
  location="./structured_array",
@@ -146,6 +171,11 @@ if __name__ == "__main__":
146
171
  "./test.hdf5", read_attrs=False
147
172
  )
148
173
 
174
+ pyhdf5_handler.get_hdf5file_item(
175
+ path_to_hdf5="./test.hdf5",
176
+ location="./mix_dtype_panda_dataframe",
177
+ )
178
+
149
179
  pyhdf5_handler.save_dict_to_hdf5file("./test.hdf5", data)
150
180
 
151
181
  # complex class with exluded datatype
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pyhdf5_handler"
7
- version = "0.8"
7
+ version = "0.9"
8
8
  authors = [
9
9
  { name="Maxime Jay-Allemand", email="maxime.jay.allemand@hydris-hydrologie.fr" },
10
10
  ]
Binary file
File without changes
File without changes