Pandas的CSV加载错误

时间:2016-11-27 20:50:21

标签: python csv pandas

有人可以帮我弄清楚这个错误告诉我的是什么吗?我不明白为什么这个csv不会加载。

代码:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace Marks
{
    internal class Program
    {
        public static float AverageOfArrayList(ArrayList Array)
        {
            float AverageOfArrayList = 0;
            float Sum = 0;

            foreach (int item in Array)
            {
                Sum += item;
            }
            AverageOfArrayList = Sum / Array.Count;
            return AverageOfArrayList;
        }
        public static ArrayList GetVariables(float CurrentAverage, double MissedAverage)
        {
            ArrayList o_NewMarksList = new ArrayList();
            if (CurrentAverage >= MissedAverage)
            {
                o_NewMarksList.Add(2);
                for (int i = 1; MissedAverage < AverageOfArrayList(o_NewMarksList); i++)
                {
                    o_NewMarksList.Add(2 + i);
                }
            }

            if (CurrentAverage <= MissedAverage)
            {
                o_NewMarksList.Add(5);
                for (int i = 1; AverageOfArrayList(o_NewMarksList) < MissedAverage; i++)
                {
                    o_NewMarksList.Add(5 + i);
                }
            }
            return o_NewMarksList;
        }
        static void Main(string[] args)
        {
            float CurrentAverage = 0;
            double MissedAverage = 0;

            //Console.WriteLine("Enter how much marks have you got");
            //int CountOfMarks = Convert.ToInt16(Console.ReadLine());

            Console.WriteLine("Enter the 1-st average");
           // CurrentAverage = float.Parse(Console.ReadLine());

            Console.WriteLine("Enter the 2-nd average");
          //  MissedAverage = Convert.ToDouble(Console.ReadLine());


            //ArrayList newList = GetVariables(CurrentAverage, MissedAverage);
            ArrayList newList = GetVariables(3, 3);
            List<int> OutputArray = newList.Cast<int>().ToList();

            Console.WriteLine("Marks to add :");

            for (int OutputCounter = 0; OutputCounter < OutputArray.Count; OutputCounter++)
            {
                Console.Write(OutputArray[OutputCounter] + " ");
            }
            Console.ReadKey();
        }
    }
}

错误:

import pandas as pd
import numpy as np
energy = pd.read_csv('Energy Indicators.csv')
GDP = pd.read_csv('world_bank_new.csv')
ScimEn = pd.read_csv('scimagojr-3.csv')

1 个答案:

答案 0 :(得分:2)

read_csv函数需要encoding option。你需要告诉Pandas文件编码是什么。试试encoding = "ISO-8859-1"