Guest User

Untitled

a guest
Jan 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. 33,Jogging,49105962326000,-0.6946377,12.680544,0.50395286;
  2. 33,Jogging,49106062271000,5.012288,11.264028,0.95342433;
  3. 33,Jogging,49106112167000,4.903325,10.882658,-0.08172209;
  4. 33,Jogging,49106222305000,-0.61291564,18.496431,3.0237172;
  5. 33,Jogging,49106332290000,-1.1849703,12.108489,7.205164;
  6. 33,Jogging,49106442306000,1.3756552,-2.4925237,-6.510526;
  7.  
  8. import numpy as np
  9. file = open("WISDM_ar_v1.1_raw.txt", "r")
  10. list_arr = file.readlines()
  11.  
  12. length = len(list_arr)
  13. list1 = []
  14. #print(length)
  15. for i in range(length):
  16. list_arr[i] = list_arr[i].rstrip("n")
  17. list_arr[i] = list_arr[i].rstrip(";")
  18. list_arr[i] = list_arr[i].split(",")
  19. if len(list_arr[i]) == 6:
  20. list1.append(list_arr[i])
  21. else:
  22. pass
  23.  
  24. array1 = np.array(list1,dtype=str)
  25. print(array1.dtype)
  26. array2 = np.delete(array1, [0,1], axis=1)
  27. print(array2.dtype)
  28. array2 = array2.astype(np.float)
  29. print(array2)
  30.  
  31. <U15
  32. <U15
  33. Traceback (most recent call last):
  34. File "D:/Anaconda/network/.idea/testfloat.py", line 22, in <module>
  35. array2 = array2.astype(np.float)
  36. ValueError: could not convert string to float:
Add Comment
Please, Sign In to add comment