如何基于三个不同的数组对数据进行网格化?

时间:2018-11-11 21:17:57

标签: python python-2.7 pandas

我有三个数组。时间,身高,然后是我在每个时间和身高处的值。这是一个很大的数据集,当我尝试执行np.meshgrid()时,出现内存错误。当我使用plt.pcolormesh进行绘制时,它可以完美绘制。

例如,如果我有一个高度数组:

 [[-3, -2, -1, 0, 1, 2],
  [-1,  0,  1, 2, 3, 4], 
  [ 1,  2,  3, 4, 5, 6]]

时间数组:

 [[1, 1, 1, 1, 1, 1],
  [2, 2, 2, 2, 2, 2], 
  [3, 3, 3, 3, 3, 3]]

然后是我的数据:

 [[22, 10, 5, NaN, 3, 7],
  [4,   2, 9,  -3, 4, 1], 
  [7,   5, 2,  -1, 4, 2]]

如何获取如下所示的网格:

   -3  -2  -1   0   1   2   3   4   5   6
 1 22  10   5 NaN   3   7  NaN NaN NaN NaN
 2 NaN NaN  4   2   9  -3   4   1  NaN NaN
 3 NaN NaN NaN NaN  7   5   2  -1   4   2

然后我打算用数据制作一个Pandas DataFrame并将其用于数据分析。

1 个答案:

答案 0 :(得分:1)

继续制作您的DataFrame,然后直接打印

const composedMiddlewares = middlewares =>
  process.env.NODE_ENV === 'development'
    ? compose(
    applyMiddleware(...defaultMiddlewares, ...middlewares),
    DevTools.instrument()
    )
    : compose(applyMiddleware(...defaultMiddlewares, ...middlewares));
const initialize = (initialState?: IRootState, middlewares = []) => {
  const store = createStore(reducer, initialState, composedMiddlewares(middlewares));
  sagaMiddleware.run(rootSaga);
  return store;
};
export const getReduxStore = (() => {
  let store = null;

  function initStoreIfRequired() {
    if (!store) {
      store = initialize();
    }
    return store;
  }

  return initStoreIfRequired;
})();
export const SERVICE_TYPES = {
  REDUX_STORE: 'REDUX_STORE',
};

export class ReduxDiModule implements IDiModule {
  addDefinitions(container: Container) {
    let reduxStore = getReduxStore();
    container.bind<object>(SERVICE_TYPES.REDUX_STORE).toConstantValue(reduxStore);
  }
}