2

I'm trying to import data from csv file and I get two different types of arrays when I use pandas' read function and numpy's getfromtxt resulting in two different arrays:

[[ 1.  0.  1. ...,  1.  0.  0.]
 [ 0.  1.  1. ...,  1.  0.  0.]
 [ 0.  1.  1. ...,  1.  0.  0.]
 ..., 
 [ 0.  1.  1. ...,  1.  0.  0.]
 [ 1.  0.  1. ...,  1.  0.  0.]
 [ 1.  0.  1. ...,  1.  0.  0.]]

When I use the following line of code:

from numpy import genfromtxt
df = genfromtxt('C:/Users/m15x/Desktop/UFABC/PDPD/inputX(editado_bits).csv', delimiter=',')

X = df

print(X)

And:

[[1 0 1 ..., 1 0 0]
 [0 1 1 ..., 1 0 0]
 [0 1 1 ..., 1 0 0]
 ..., 
 [1 0 1 ..., 1 0 0]
 [1 0 1 ..., 0 0 1]
 [1 0 1 ..., 1 0 0]]

When I use the this line of code:

import pandas as pd

df = pd.read_csv('C:/Users/m15x/Desktop/UFABC/PDPD/input(editado_bits).csv')

X1 = df.loc[0:86,'Initiation (Gradual)' : 'Otoscopy (cerumen)']
X = X1.values

print(X)

What is the difference between them?

Rafael Lee
  • 43
  • 1
  • 3
  • No dot means integers and they are exact values so long as they are small enough. Dot means float and considering that machines are binary, they are inexact, but very close. – piRSquared Sep 29 '17 at 00:32

1 Answers1

0

Try in Python shell:

>>> type(1.)
<class 'float'>
>>> type(1)
<class 'int'>
Michael Butscher
  • 10,028
  • 4
  • 24
  • 25