in Education by
Hi Everyone I'm Having This Two Columns: Mi_Meteo['Measurement'] = Mi_Meteo['Measurement'].str.rstrip(' Measure') Mi_Meteo['Measurement'].head() 0 0.8 1 0.6 2 0.4 3 0.4 4 0 Name: Measurement, dtype: object And: Mi_Meteo['Sensor_ID'] = Mi_Meteo['Sensor_ID'].str.rstrip(' ID') Mi_Meteo['Sensor_ID'].head() 0 14121 1 14121 2 14121 3 14121 4 14121 Name: Sensor_ID, dtype: object So , i tried to convert both of them to float , nut was got an error: Mi_Meteo['Measurement'] = Mi_Meteo['Measurement'].astype(float) ValueError: could not convert string to float: And: Mi_Meteo['Sensor_ID'] = Mi_Meteo['Sensor_ID'].astype(float) ValueError: could not convert string to float: Any Suggestion , would be much appreciated , thank U all. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
One possible reason could be some white space in your data which didn't clear out. Add in str.strip() before converting to float. Mi_Meteo['Measurement'] = Mi_Meteo['Measurement'].str.rstrip(' Measure').str.strip() Mi_Meteo['Measurement'] = Mi_Meteo['Measurement'].astype(float)

Related questions

0 votes
    Hi Everyone I'm Having This Two Columns: Mi_Meteo['Measurement'] = Mi_Meteo['Measurement'].str.rstrip(' ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I'm testing such sentence to extract entity values: s = "Height: 3m, width: 4.0m, others: 3.4 ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Convert pandas DateTimeIndex to Unix Time? (7 answers) Closed 3 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    How will you convert a string to a float in python?...
asked Nov 24, 2020 in Technology by JackTerrance
0 votes
    What's the proper way to convert from a scientific notation string such as "1.234567E-06" to a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 26, 2022 in Education by JackTerrance
0 votes
    Hi I'm having some issues showing lists in my embed correctly. I'm trying to get my roles to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I used the function for gower distance from this link: https://sourceforge.net/projects/gower-distance- ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have two Dataframes : DF1(That i've just resampled): Mi_pollution.head(): Sensor_ID Time_Instant ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 3, 2022 in Education by JackTerrance
0 votes
    I'm creating my first program on python. The objective is to get an output of trip cost. In the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I am looking to write a pop-up window which asks the user to select a specific option, and if ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I need to find a message the bot has previously posted, then see the reactions on it. I don't ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    When you just want to do a try-except without handling the exception, how do you do it in Python? Is the ... rmtree(path) except: pass Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    I have two integer values a and b, but I need their ratio in floating point. I know that a < b, and I want ... the following? c= a / b Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me how I can represent the equivalent of an Enum in Python? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
...