我有一个很大的熊猫数据框,如下所示:
System.out.println("Q1.HOW DO YOU RECHARGE?");
System.out.println("A. SPENDING TIME ALONE");
System.out.println("B. PUBLIC DISCUSSIONS OR PARTIES");
System.out.println("C. BOTH OF THEM ARE FINE IF I'M IN THE MOOD");
char choice1 = (char)br.read();//this line gets executed perfectly fine
if(choice1 == 'A')
ct+=20;
else if(choice1 == 'B')
ct+=10;
else
ct+=30;
System.out.println("Q2.ARE YOU OPEN TO NEW PEOPLE?");
System.out.println("A. YES OF COURSE");
System.out.println("B. I DON'T WANT TO TALK TO NEW PEOPLE");
System.out.println("C. I CAN'T OPEN UP TO NEW PEOPLE UNTIL THEY ARE CLOSE ENOUGH");
char choice2 = (char)br.read();//this one doesn't
if(choice2 == 'A')
ct+=10;
else if(choice2 == 'B')
ct+=20;
else
ct+=30;
System.out.println("Q3.WOULD YOU GO FIRST OR LAST FOR A PRESENTATION?");
System.out.println("A. I GUESS I WOULD GO FIRST ONLY IF I'M VERY CONFIDENT");
System.out.println("B. OF COURSE FIRST!");
System.out.println("C. NO. SO THAT I CAN LEARN FROM OTHER'S MISTAKES");
char choice3 = (char)br.read();//this does
if(choice3 == 'A')
ct+=30;
else if(choice3 == 'B')
ct+=10;
else
ct+=20;
由于数据帧非常大,因此我想将其存储在一个包含一部分数据帧的文件中(假设3个文件占每个数据帧的33%)。有什么办法吗?
答案 0 :(得分:1)
当然,将其拆分:
split1 = len(df) // 3
split2 = split1 * 2
df.iloc[:split1].to_json(...)
df.iloc[split1:split2].to_json(...)
df.iloc[split2:].to_json(...)
每个文件写一列可能更有意义:
for col in df.columns:
df[col].to_json(...)