将大量数据帧组合到一个数据帧中而不会出现内存错误?

时间:2017-11-29 08:48:44

标签: python-3.x

我有一个庞大的数据框列表(时间序列)(列表中超过5500个条目,每个条目有750 x 2大小)。如何将其组合到单个数据帧中而不会出现内存错误?

我尝试过使用pandas.merge,pandas.concat,但没有任何工作

1 个答案:

答案 0 :(得分:0)

您没有提供任何代码,因此我不知道您的设置是什么样的,但请考虑以下概念。

#include <stdio.h> // for input/output

#define BUFSIZE 1024
#define NAMESIZE 100

// this is your struct
typedef struct
{
    char *nome;
    int numero;
    float salario;
    int inicio_contrato;
    int anos_contrato;
    int forca_defesa;
    int forca_medio;
    int forca_avancado;
    int forca_guardaredes;
} jogadores;

int main()
{
    char buf[BUFSIZE], name[NAMESIZE], c;
    int i;

    // the name is handled seperately
    for (i = 0; (c = getchar()) != ';' && i < NAMESIZE - 1; i++) {
        name[i] = c;
    }
    name[i] = 0; // terminate the string

    // the rest of the line is read into a buffer
    for (i = 0; (c = getchar()) != EOF && i < BUFSIZE - 1; i++) {
        buf[i] = c;
    }
    buf[i] = 0; // terminate the string

    // the struct is created and the name is copied into the struct
    jogadores entry;
    entry.nome = name;

    // the numbers of the remaining line are read in
    sscanf(buf, "%d;%f;%d;%d;%d;%d;%d;%d;",
        &entry.numero, &entry.salario, &entry.inicio_contrato,
        &entry.anos_contrato, &entry.forca_defesa, &entry.forca_medio,
        &entry.forca_avancado, &entry.forca_guardaredes);

    // the whole struct is printed
    printf("%s\n%d\n%f\n%d\n%d\n%d\n%d\n%d\n%d\n",
        entry.nome, entry.numero, entry.salario, entry.inicio_contrato,
        entry.anos_contrato, entry.forca_defesa, entry.forca_medio,
        entry.forca_avancado, entry.forca_guardaredes);

    return 0; // tell the caller that everything went fine
}