Вопрос

I am using pandas to join several huge csv files using HDFStore. I'm merging all the other tables to a base table, base. Right now I create a new table in the HDFStore for the output of each merge, which I call temp. Then I delete the old base table. Finally, I copy temp to base and start the process over again on the next table I need to join.

This would be much more efficient if I could simply rename temp to base. Is this possible?

Это было полезно?

Решение

Yes, it is possible. You have to delve into the methods from PyTables, on which HDFStore depends.

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_table appendable nodes.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top