user13673216
user13673216

Reputation:

problems with read.csv in python

I'm trying to import some data in python with dati_input=pd.read_csv('prova_dati.csv', header=0), because the first row contains labels. My data have two columns and 96 rows and each column has a header. Then I want to save the data in the first column in a variable, so I've used x=dati_input.iloc[:,0].values, where dati_input is the csv file's name. But when I do print x I obtain an array in which the single value is a concatenation of the value present in the first and second column of each row, like this

array(['67.28;61.562504038486864', '67.28;63.45779481177123',
      '67.28;64.73018976405686', '67.28;65.45396258335259',
      '67.28;65.70338695766725', '67.28;65.54753698144073',
      '67.28;65.03468837483717', '67.28;64.20791726445185',
      '67.28;63.11029977687992', '67.28;61.830841536446506',
      '67.28;60.64226615839608', '67.28;59.863226755703025'])

Also, I don't understand why the values are separated by ; and why there are the apexes if they are numbers. Could anyone help me to understand where I'm wrong? Thank you so much.

Upvotes: 0

Views: 496

Answers (1)

Louis Mc Dougall
Louis Mc Dougall

Reputation: 21

It seems like your values are separated by a semicolon in your original csv file. You could do : dati_input=pd.read_csv('prova_dati.csv', header=0, sep=';') to avoid the concatenation.

Upvotes: 2

Related Questions