-1

I currently do not get it. I am following the example here. I got the following data in a csv file:

  Class; Value; Class start; Class end;
    1;3;-0.500000000000;-0.496093750000;
    2;4;-0.496093750000;-0.492187500000;
    3;1;-0.492187500000;-0.488281250000;
    4;8;-0.488281250000;-0.484375000000;
    5;5;-0.484375000000;-0.480468750000;
    6;2;-0.480468750000;-0.476562500000;
    7;1;-0.476562500000;-0.472656250000;
    8;3;-0.472656250000;-0.468750000000;
    9;1;-0.468750000000;-0.464843750000;
    10;2;-0.464843750000;-0.460937500000;
    11;3;-0.460937500000;-0.457031250000;
    12;3;-0.457031250000;-0.453125000000;
    13;7;-0.453125000000;-0.449218750000;
    14;0;-0.449218750000;-0.445312500000;
    15;5;-0.445312500000;-0.441406250000;
    16;4;-0.441406250000;-0.437500000000;
    17;1;-0.437500000000;-0.433593750000;
    18;0;-0.433593750000;-0.429687500000;
    19;5;-0.429687500000;-0.425781250000;
    20;5;-0.425781250000;-0.421875000000;
    21;7;-0.421875000000;-0.417968750000;
    22;2;-0.417968750000;-0.414062500000;

I read this by Pandas:

data=pd.read_csv ("C:\hist\AIR_09-10.csv", sep=';')
print ("Totalrows: {0}".format(len(data)))
Totalrows: 256

This works:

test = data[data.Class == 1]
print test

Result in :

       Class   Value   Class start   Class end  Unnamed: 4
0      1       3          -0.5   -0.496094         NaN

But what is that first column "29" and what means "Unnamed: 4" and how can I get several of these files in something like here.

This :

hist = data.hist(bins=100, column=data[data.Value])

Gives:

AttributeError: 'DataFrame' object has no attribute 'Value'

Cœur
  • 37,241
  • 25
  • 195
  • 267
dh81
  • 67
  • 10

1 Answers1

0

"Unnamed: 4" is generated as pandas an EOL and not ";" as a closing character of a row. It thinks that there is an extra unnamed column.

To make the histogram work the documentation. To make it work use the following code:

hist = data['class'].hist(bins=100)
user2874583
  • 537
  • 1
  • 4
  • 13
  • With that "Class" is working, but nothing else, e.g. "Value", which would be neccessary. Thus, the import reads "Class" but not "Value" or else. I fixed this by importing: data=pd.read_csv ("C:\hist\AIR_09-10.csv", sep=';', names=['Class', 'Value', 'Class start', 'Class end','none'], skiprows=1) – dh81 Jul 11 '18 at 13:19