假设我有一个pandas数据框(Dataframe)
import pandas as pd
df = pd.DataFrame()
df
Column1 Column2
0 0.189086 -0.093137
1 0.621479 1.551653
2 1.631438 -1.635403
3 0.473935 1.941249
4 1.904851 -0.195161
5 0.236945 -0.288274
6 -0.473348 0.403882
7 0.953940 1.718043
8 -0.289416 0.790983
9 -0.884789 -1.584088
........
查询的一个示例是 df.query('Column1 > Column2')
假设您想限制此查询的保存,使对象不那么大。有没有“pandas”方法可以实现这一点?
我的问题主要是针对使用pandas查询HDF5对象。 HDF5对象可能比RAM大得多,因此查询可能比RAM大。
# file1.h5 contains only one field_table/key/HDF5 group called 'df'
store = pd.HDFStore('file1.h5')
# the following query could be too large
df = store.select('df',columns=['column1', 'column2'], where=['column1==5'])
有没有一种pandas/Pythonic的方法来阻止用户执行超过一定大小的查询?
store.select(...)
时使用chunksize
参数怎么样? - MaxU - stand with Ukraine