BUG: to_hdf and HDFStore for subclasses
- [ ] closes #33748
- [ ] tests added / passed
- [ ] passes `black pandas`
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

Fix the bug that the subclasses of a dataframe and a series cannot be saved ``to_hdf``.
The tests were added.
When testing I found that ``assert_frame_equal`` does not work on subclasses as well - probably need to fix it in a separate PR.
For now in the tests I compare values only.