2

I am just getting started with numpy. So, just to play around I downloaded FIFA 18 Complete Player Dataset. Then, I tried to run a simple code :

import numpy as np
np_fifa = np.genfromtxt('Datasets/FIFA2018.csv', delimiter=',')
print(np_fifa)

But it immediately shows this error :

Traceback (most recent call last):
File "C:\MyFiles\Programs\Python\PlayGround.py", line 2, in
np_fifa = np.genfromtxt('Datasets/FIFA2018.csv', delimiter=',')
File "C:\Users\Vaibhav Acharya\AppData\Local\Programs\Python\Python36-32\lib\site-packages\numpy\lib\npyio.py", line 1951, in genfromtxt
for (i, line) in enumerate(itertools.chain([first_line, ], fhd)):
File "C:\Users\Vaibhav Acharya\AppData\Local\Programs\Python\Python36-32\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 2250: character maps to undefined

1 Answers1

1

Thanks to Cr3 for helping me through comments. At last this code worked for me:

import numpy as np
fifa = np.genfromtxt('Datasets/CompleteDataset.csv', delimiter=',', encoding='utf-8', dtype=str)
np_fifa = np.array(fifa)
print(np_fifa)

Output :

[['' 'Name' 'Age' ... 'RW' 'RWB' 'ST']
['0' 'Cristiano Ronaldo' '32' ... '91.0' '66.0' '92.0']
['1' 'L. Messi' '30' ... '91.0' '62.0' '88.0']
['17978' 'J. Young' '17' ... '44.0' '32.0' '45.0']
['17979' 'J. Lundstram' '18' ... '44.0' '46.0' '41.0']
['17980' 'L. Sackey' '18' ... '29.0' '38.0' '31.0']]