Renaming a table in pandas hdfstore

I use pandas to combine several huge csv files using HDFStore. I combine all the other table into the base table base. Now I am creating a new table in HDFStore to display each merge that I call temp. Then I delete the old base table. Finally, I copy tempin baseand start the process again in the following table in which I need to join.

It would be much more efficient if I could just rename tempto base. Is it possible?

+4
source share
1 answer

Yes it is possible. You need to delve into the methods from PyTables that you depend on HDFStore.

Out[20]: 
<class 'pandas.io.pytables.HDFStore'>
File path: test.h5
/a            frame        (shape->[3,1])

In [21]: store.get_node('a')._f_rename('b')

In [22]: store
Out[22]: 
<class 'pandas.io.pytables.HDFStore'>
File path: test.h5
/b            frame        (shape->[3,1])

The same method works on frame_tablejoining nodes.

+5
source

Source: https://habr.com/ru/post/1534542/


All Articles