My Error: unknown extension ?Pd at position 1 - kaggle

I saw this error:
unknown extension ?Pd at position 1
in
temp_nums = weather["temp"].str.extract("(?Pd+)", expand=False)
weather["temp_num"] = temp_nums.astype('int')
temp_nums

Where it says (?Pd+), type (?P<temp_num>\d+) instead like they did on this
example.

Related

How to use mapFieldType with gdal.VectorTranslate

I'm trying to export a postgresql database into a .gpkg file, but some of my fields are lists, and ogr2ogr send me the message :
Warning 1: The output driver does not natively support StringList type for field my_field_name. Misconversion can happen. -mapFieldType can be used to control field type conversion.
But, as in the documentation, -mapFieldType is not a -lco, i don't find how to use it with the python version of gdal.VectorTranslate
here ma config :
gdal_conn = gdal.OpenEx(f"PG:service={my_pgsql_service}", gdal.OF_VECTOR)
gdal.VectorTranslate("path_to_my_file.gpkg"), gdal_conn,
SQLStatement=my_sql_query,
layerName=my_mayer_name,
format="GPKG",
accessMode='append',
)
so i've tried to add it in the -lco :
layerCreationOptions=["-mapFieldType StringList=String"]
but it didn't work
so i diged into the code of gdal, added a field mapFieldType=None into the VectorTranslateOptions function, and added into its code the following lines :
if mapFieldType is not None:
mapField_str = ''
i = 0
for k, v in mapFieldType.items():
i += 1
mapField_str += f"{k}={v}" if i == len(mapFieldType) else f"{k}={v},"
new_options += ['-mapFieldType', mapField_str]
And it worked, but is there an other way ?
And if not, where can i propose this feature ?
Thank you for your help

Error trying to get selected font from py QFontComboBox using activated.connect

(in PyQt5)
I am trying to get the name of the selected font from QFontComboBox to "showInfo" and an error occurs (detail after the code).
The code below is not part of a class.
Thanks!
def additional_menu_styled_font(editor):
projCombo = QFontComboBox
objectTest = QObject()
ShapeLayerList = QWidgetAction(objectTest)
ShapeLayerList.setDefaultWidget(projCombo())
popupMenu2A = QMenu()
popupMenu2A.setTitle("Shape Data")
popupMenu2A.addAction(ShapeLayerList)
popupMenu2A.exec_(QCursor.pos())
#fixme!!!
projCombo().activated.connect(changed)
Editor.additional_menu_styled_font = additional_menu_styled_font
def changed(projCombo):
showInfo(str(projCombo().currentFont().family()))
And the error:
...in additional_menu_styled_font
projCombo().activated.connect(changed)
TypeError: connect() failed between activated(int) and unislot()

Error as "String index out of range: -1" with set keyword in Karate

Below is the code snippet for which I am getting an error.
* def json = {"test" : { "data.a":'value',"data.b":'value2' }}
* print json.test["data.a"] // This line is working getting value 'value'
* set json.tes["data.a"] = 'hello' // This line is failing with error "String index out of range: -1
Response:
[java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1967)
at com.intuit.karate.JsonUtils.setValueByPath(JsonUtils.java:257)
at com.intuit.karate.Script.setValueByPath(Script.java:1519)
at com.intuit.karate.Script.setValueByPath(Script.java:1489)
at com.intuit.karate.Script.setValueByPath(Script.java:1479)
at com.intuit.karate.StepDefs.setNamedByPath(StepDefs.java:572)
at com.intuit.karate.StepDefs.setByPath(StepDefs.java:562)
at ✽.* set json.tes["data.a"] = 'hello' // This line is failing with error "String index out of range: -1
Not able to set value for "data.a" dynamically using SET keyword.
Please help.
This seems to be very badly designed JSON. Make a small change, use eval:
* eval json.test["data.a"] = 'hello'

Mule 4, get uri params with Anypoint application

I'm new in Mulesoft, I'm following Quickstart guide. In Step 2 (https://developer.mulesoft.com/guides/quick-start/developing-your-first-mule-application), I need to receive variables from URI in this way:
[{'id' : attributes.uriParams.productId}]
But when I try my GET I have the following error in console:
**Message : "Cannot coerce Array ([{id: "2" as String {class: "java.lang.String"}}]) to Object 1| [{'id' : attributes.uriParams.productId}] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Trace: at main (line: 1, column: 1)" evaluating expression: "[{'id' : attributes.uriParams.productId}]". Error type : MULE:EXPRESSION Element : get:\products(productId):test_daniel-config/processors/1 # test6_db_connection:test_daniel.xml:133 (Select) Element XML : SELECT product.,CONCAT('["', (GROUP_CONCAT(variant.picture SEPARATOR '","')),'"]') AS pictures,CONCAT('[', GROUP_CONCAT('{"',variant.identifierType, '":"', variant.identifier, '"}'),']') AS identifiersFROM product INNER JOIN variant ON product.uuid = variant.productUUIDWHERE product.uuid = :id; #[[{'id' : attributes.uriParams.productId}]] *
Any Ideas? Thanks!
cannot coerce Array to object error pop's up when you are using an array where you were supposed to use an object.
in the exception above the uri-param should be treated as ab object i.e. enclosed in {} but its being treated as an array of objects [{}].
this is causing the error.

*** glibc detected *** ./test: free(): invalid pointer:

I am trying to fetch and store ID and Status from Database using statements ID = r->getInt(1) and stat = r->getString(10) where I have declared ID as int and stat as string.
Where first field is an ID containing value 1 and 10th field is status containing value 'A'.
If I try to fetch only ID, my code works fine. Else, when I try to fetch status as well, then while running the code, I am getting below mentioned error:
*** glibc detected *** ./test: free(): invalid pointer: 0x000000001c3f5a60 ***
======= Backtrace: =========
/lib64/libc.so.6[0x3d23e71684]
/lib64/libc.so.6(cfree+0x8c)[0x3d23e74ccc]
/usr/lib64/libstdc++.so.6(_ZNSsD1Ev+0x3a)[0x3d28a9dc1a]
./test[0x401837]
./test(__gxx_personality_v0+0x310)[0x401120]
/lib64/libc.so.6(__libc_start_main+0xf4)[0x3d23e1d8b4]
./test(__gxx_personality_v0+0x89)[0x400e99]
Please help.
Adding just the basics of what I am trying to achieve:
char loader_session[10];
char sql_query[500];
int ID;
string STATUS;
string CURRENT_CNT_FILE
env = Environment::createEnvironment (Environment::DEFAULT);
conn = env->createConnection( user, passwd, db);
strcpy(loader_session,"TEST");
sprintf(sql_query,"SELECT ID, SESSION_NAME, SRC_SUCCESS_PATH, SRC_CDR_PATH, LOG_FILE, CURRENT_CNT_FILE, LOG_MAX_FILE_CNT, LOG_MAX_FILE_SIZE, PROCEDURE_NAME, STATUS, ERROR_CDR_PATH, LOCK_FILE_PATH FROM TEST_DB WHERE SESSION_NAME = '%s'",loader_session);
Statement* const s = conn->createStatement(sql_query);
s->setPrefetchRowCount(10);
ResultSet* const r = s->executeQuery();
while (r->next())
{
ID = r->getInt(1);
STATUS = r->getString(10);
CURRENT_CNT_FILE = r->getString(6);
}
Ok I got a temporary solution for my question. Just by setting MALLOC_CHECK_ to 0, I am not getting the error and my code is running fine. Don't know the side effects of this, but as of now, it's working fine.