快速pytables熊猫数据切片

问题描述 投票:0回答:1

我的运行速度很慢。我的数据是

 <class 'pandas.io.pytables.HDFStore'>
 File path: c:/data/bed_1/acc_ohlc.hdf
 /000020            frame        (shape->[7721,5])
 /000030            frame        (shape->[1037,5])
 /000040            frame        (shape->[7723,5])
 /000050            frame        (shape->[7723,5])
 /000060            frame        (shape->[7723,5])
 /000070            frame        (shape->[7724,5])
 /000080            frame        (shape->[2426,5])

每个都是熊猫数据帧,每个数据长度都不同。索引是时间戳。用于创建具有相同期间数据的新数据集。

  begin = '20140117'
  end = '20150116'   
  p_data = {}
  for index, row in code_list.iterrows():
      code = row['Code'][:-3]
      p_data[code] = store[code].ix[begin:end].astype (float)
  new_data = pd.Panel(p_data)

new_data = pd.Panel(p_data)

总运行时间约为25秒。有什么好的代码可以缩短运行时间吗?

python pandas pytables
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.