could not convert string to float: 'Urban' - azure-databricks

I have extracted the columns data from "Data.xls" file and have 1 column(Location_type) and the values contains.
Location_type
Urban
Rural
And i am getting could not convert string to float: 'Urban' for the above column.
I have tried multiple way trying to convert :
df.Location_type=df.Location_type.astype(float)
df['Location_type']=df['Location_type'].astype(float)
Trying all the above-mentioned syntax for the particular column.After applying still i am getting error:
could not convert string to float: 'Urban'
Please advise.
Regards
Rohit

Related

ImageSegmentationAnnotation Class seems to not work while giving the path to the annotations BitMaps

I am not able to figure out correct Key, Value names to pass out bitmap labels to a Image Segmentation problem in vertex AI. My error message is below:
Error: Could not parse the line, json is invalid or the format does not match the input schema: Cannot find field: ImageSegmentationAnnotation.MaskAnnotation in message google.cloud.aiplatform.master.schema.ImageSegmentationIoFormat. for: gs://starry-embassy-363916-image/Figaro1k_json.jsonl line 3
Error: Could not parse the line, json is invalid or the format does not match the input schema: Cannot find field: ImageSegmentationAnnotation.MaskAnnotation in message
And the format of the .jsonl file I am giving is :
{"imageGcsUri": "gs://starry-embassy-363916-image/Figaro1k/Original/Training/Frame00003-org.jpg", "ImageSegmentationAnnotation.MaskAnnotation" : [{"mask_gcs_uri": "gs://starry-embassy-363916-image/Figaro1k/GT/Training/Frame00003-gt.pbm"}], "dataItemResourceLabels": {"aiplatform.googleapis.com/ml_use": "training"}}
TIA
I tried various combination of the ImageSegmentationAnnotation class as documented here:
https://cloud.google.com/vertex-ai/docs/reference/rpc/google.cloud.aiplatform.v1/schema#google.cloud.aiplatform.v1.schema.ImageSegmentationAnnotation
And here:
https://cloud.google.com/vertex-ai/docs/image-data/classification/prepare-data#json-lines_1

How to take xpath to Get Text from class inside th

I have the following XPath :
//table[#class='ui-jqgrid-htable']/thead/tr/th//text()
And I'm trying to get the text from it with the following command :
String LabelName = driver.findElement(By.xpath("//table[#class='ui-jqgrid htable']/thead/tr/th//text()")).getText()
But it's not printing text, the result is blank. Could you help me please ?
The text() in your xpath does not qualify as an element. Your element ends at //table[#class='ui-jqgrid-htable']/thead/tr/th. Try using getText() for this XPath.
Also, a table would have many headers. Using findElement will only return the first one.
If you want to get all headers use
driver.findElements(By.xpath("//table[#class='ui-jqgrid-htable']/thead/tr/th"))
and loop through the list to getText of individual element.

worksheet.format("A2:A", { "numberFormat": { "type": "DATE_TIME" }}) doesn't work for text

I'm trying to log temperature and humidity to a google spreadsheet using gspread and python.
That works, however when I insert a row using the following code:
worksheet.append_row((datetime.datetime.now().strftime("%d-%m-%Y %H:%M:%S"), temp, humidity))
now for example cell 'A2' has the value: '12-05-2020 00:11:50 (Note the single quotation mark)
I want the data to be represented in a chart. This cannot be done with the above value so I have to convert it to a date_time value.
worksheet.format("A2:A", { "numberFormat": { "type": "DATE_TIME" }})
I expect the entire column to be converted to Date Time. This doesn't convert the values with a single quotation mark.
I spend the whole day trying to get this to work but for some reason I can't seem to find a way to have a 'normal' date_time value added that Google Sheets recognizes as a date_time...
If I enter a (numeric) value manually in a cell in column A. The code to set the format works just fine.
Also if I manually select the column and select he formatting from the menu it works fine with the gspread added date time rows.
I really want it to be done programmatically and not by hand of course.
Any help is greatly appreciated.
In that case, please use value_input_option as follows. By this, the date is put as the date object.
From:
worksheet.append_row((datetime.datetime.now().strftime("%d-%m-%Y %H:%M:%S"), temp, humidity))
To:
worksheet.append_row((datetime.datetime.now().strftime("%d-%m-%Y %H:%M:%S"), temp, humidity), value_input_option="USER_ENTERED")
Reference:
append_rows(values, value_input_option='RAW', insert_data_option=None, table_range=None)
ValueInputOption

metafor package, rma.uni, mods, Model matrix contains character variables

I'm trying to run a meta-regression with MD's as dependent variable. I want to add a numeric moderator (year published) to the rma.uni function.
Formula so far:
metafor::rma.uni(yi=MCID12, sei=SE12, method="FE", data=Pain, slab=paste(Pain$Author, Pain$Year), weighted=TRUE, subset=(Pain$outcomegruppe=="9"), mods =("Pain$Year") )
I always get the error message:
Error in metafor::rma.uni(yi = MCID12, sei = SE12, method = "FE", data = Pain, :
Model matrix contains character variables.
My "Year" veriable is definetly numeric. As soon as I don't use the "mods" argument, everything works normal.
Could anyone help me with this problem?
Thanks in advance!
Don't put Year in quotes. Also, you don't need the Pain$ parts and weighted=TRUE is the default. This should do it:
metafor::rma.uni(yi=MCID12, sei=SE12, method="FE", data=Pain, slab=paste(Author, Year),
subset=(outcomegruppe=="9"), mods=~Year)

Correct strptime format for Input Type Time on Rails 4

Want to use the
<input name=attendance[something] type="time">
For time input. However cant make it seem to match with a Datetime object; for manipulation before insertion to ActiveRecord
myTimeIn = Time.strptime(params[attendance][something],"%H:%M")
keeps getting
invalid strptime format - `%H:%M'
What is the correct format for a input type=time field?
Looks like the value of params[attendance][something] may be blank or not of the correct format. You could do something like below to avoid the error:
t = params[attendance][something]
myTimeIn = Time.strptime(t,"%H:%M") if t =~ /\d{1,2}:\d{2}/
As per this HTML example, the value produced by <input/> of type time is HH:MM

Resources