Python Forum
The problem of converting string to float by using CSV file
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The problem of converting string to float by using CSV file
#3
(Jul-11-2017, 02:23 PM)ichabod801 Wrote: I tried adding python tags to your code, but it still losing the indentation. Please see the BBCode tutorial link in my signature and repost your code with proper formatting. Also post the entire traceback for the error you are getting. And your csv data doesn't look like it's in csv format. I don't see any commas. Is whatever is loading the data expecting commas? If it can handle the format of your data, my guess is that there is something in your data that is not a floating point number, like N/A or something. You'll need to clean up your data before you can process it.
OK, I will repost my code later. The data doesn't copy from the CSV file so that there is not commas there. I already checked my data. There is no N/A or missing value inside.

(Jul-11-2017, 02:23 PM)ichabod801 Wrote: I tried adding python tags to your code, but it still losing the indentation. Please see the BBCode tutorial link in my signature and repost your code with proper formatting. Also post the entire traceback for the error you are getting. And your csv data doesn't look like it's in csv format. I don't see any commas. Is whatever is loading the data expecting commas? If it can handle the format of your data, my guess is that there is something in your data that is not a floating point number, like N/A or something. You'll need to clean up your data before you can process it.
Here is the trace error:

WARNING:tensorflow:From D:\Anaconda4.4.0\envs\tensorflow\lib\site-packages\tensorflow\python\util\tf_should_use.py:170: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02.
Instructions for updating:
Use tf.global_variables_initializer instead.




---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-6-39b7fba5be19> in <module>()
84
85
---> 86 train_neural_network(x)

<ipython-input-6-39b7fba5be19> in train_neural_network(x)
73
74 _, c = sess.run([optimizer, cost], feed_dict={x: batch_x,
---> 75 y: batch_y})
76 epoch_loss += c
77 i+=batch_size

D:\Anaconda4.4.0\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)
787 try:
788 result = self._run(None, fetches, feed_dict, options_ptr,
--> 789 run_metadata_ptr)
790 if run_metadata:
791 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

D:\Anaconda4.4.0\envs\tensorflow\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
966 feed_handles[subfeed_name] = subfeed_val
967 else:
--> 968 np_val = np.asarray(subfeed_val, dtype=subfeed_dtype)
969
970 if (not is_tensor_handle_feed and

D:\Anaconda4.4.0\envs\tensorflow\lib\site-packages\numpy\core\numeric.py in asarray(a, dtype, order)
529
530 """
--> 531 return array(a, dtype, copy=False, order=order)
532
533

ValueError: could not convert string to float: 'train2.CSV'
Reply


Messages In This Thread
RE: The problem of converting string to float by using CSV file - by CChen - Jul-11-2017, 03:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem of converting Matlab code to python DongyanZ 2 1,428 Feb-03-2023, 01:04 PM
Last Post: jefsummers
Sad ValueError: could not convert string to float badju 0 4,348 Jul-01-2021, 12:13 AM
Last Post: badju
  Indirectlty convert string to float in JSON file WBPYTHON 6 5,984 May-06-2020, 12:09 PM
Last Post: WBPYTHON
  ValueError: could not convert string to float RahulSingh 3 4,257 Apr-09-2020, 02:59 PM
Last Post: dinesh
  Help batch converting .json chosen file to MySQL BrandonKastning 2 2,367 Mar-14-2020, 09:19 PM
Last Post: BrandonKastning
  ValueError: could not convert string to float: '4 AVENUE' Kudzo 4 5,976 Jan-26-2020, 10:47 PM
Last Post: Kudzo
  Converting Dataframe in Python from Object to Float marco_ita 11 13,230 Jan-09-2020, 12:33 PM
Last Post: jefsummers
  [split] Converting excel file to txt file unexceptionalhobby 2 4,393 Oct-16-2019, 06:34 PM
Last Post: unexceptionalhobby
  Converting string the pandas dataframe chrismc 0 2,371 Jan-24-2019, 11:07 AM
Last Post: chrismc
  ValueError: could not convert the string to float Grin 3 10,275 Jun-14-2018, 08:17 PM
Last Post: killerrex

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020