熊猫在AWS ubuntu上重新采样内存错误?

时间:2019-03-27 11:20:20

标签: python python-3.x pandas dataframe

AWS Ubuntu 18.04

当我在本地计算机上运行以下命令时,它可以正常工作。但是,在AWS上它给出了内存错误。我看到了一堆问题/答案,但似乎没有一个合适的解决方案。

import os
import sqlite3
import pandas as pd
import datetime

loc_tick = '/home/xxx/tick_data'
    os.chdir(loc_tick)

# Reqd sql db
conn = sqlite3.connect('tick.db', detect_types=sqlite3.PARSE_DECLTYPES, timeout=20, isolation_level=None)
m1df = pd.read_sql('select * from usdinrtick order by timestamp DESC limit 100000', conn)
#if there is a better way to select data while making sure I get the last 400-ish minutes I am all ears

m1df.set_index('timestamp', drop=True, inplace=True)

# convert to min data

m1df = m1df.resample('60S').ohlc()

我得到以下内容

  

回溯(最近通话最近):    文件“”,第1行,位于    在f中的文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/resample.py”,行865      返回self._downsample(_method)    _downsample中的文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/resample.py”,行1020      self.grouper,axis = self.axis).aggregate(how,** kwargs)    汇总文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/groupby/generic.py”,行1315      返回super(DataFrameGroupBy,self).aggregate(arg,* args,** kwargs)    总计186行的文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/groupby>/generic.py”      结果如何= self._aggregate(arg,_level = _level,* args,** kwargs)    _aggregate中的文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/base.py”,行356      ** kwargs),无    _try_aggregate_string_function中的文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/base.py”,第312行      返回f(* args,** kwargs)    在ohlc中的文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/groupby/groupby.py”,第1319行      lambda x:x._cython_agg_general('ohlc'))    _apply_to_column_groupbys中的第1492行,文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/groupby/generic.py”      keys = self._selected_obj.columns,axis = 1)    在concat中的文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/reshape/concat.py”,第228行      复制=复制,排序=排序)     init 中的文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/reshape/concat.py”,第259行      objs =列表(objs)    文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/groupby/generic.py”,行1490,在      (func(col_groupby)为_,col_groupby    在第1319行中输入文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/groupby/groupby.py”      lambda x:x._cython_agg_general('ohlc'))    _cython_agg_general中的第832行,文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/groupby/groupby.py”      min_count = min_count)    总计548行的文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/groupby/ops.py”      min_count = min_count)    _cython_operation中的文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/groupby/ops.py”,行495      标签_,_ = self.group_info    > pandas._libs.properties.CachedProperty中的文件“ pandas / _libs / properties.pyx”,第36行。获取    在group_info中的文件“ /home/sid/.local/lib/python3.6/site-packages/pandas/core/groupby/ops.py”,第731行      rep = np.diff(np.r_ [0,self.bins])    在 getitem 中的文件“ /home/sid/.local/lib/python3.6/site-packages/numpy/lib/index_tricks.py”,第404行      res = self.concatenate(元组(objs),axis = axis)   MemoryError

该代码在本地计算机上运行没有问题,并在AWS ubuntu 18.04上始终出现此错误的部分使我感到非常困惑,无法理解如何准确地对其进行调试/故障排除。

TIA

0 个答案:

没有答案