Space in f-string leads to ValueError: Invalid format specifier

Advertisements A colleague and I just stumbled across an interesting problem using an f-string. Here is a minimal example: >>> f"{ 42:x}" ‘2a’ Writing a space after the hexadecimal type leads to a ValueError: >>> f"{ 42:x }" Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Invalid format specifier I understand… Read More Space in f-string leads to ValueError: Invalid format specifier

applying str_split_fixed function simultaneously across multiple columns in r

Advertisements I have a data frame which is having multiple columns each column is having string values. I want to split column values by coma separator in the output data frame. Input and required output are as below Col1=c("a,b,c","9,a,5") Col2=c("c,b,e","4,r,t") Col3=c("e,f,g","y,z,d") Input=data.frame(Col1,Col2,Col3) Column1=c("a","9") Column2=c("b","a") Column3=c("c","5") Column4=c("c","4") Column5=c("b","r") Column6=c("e","t") Column7=c("e","y") Column8=c("f","z") Column9=c("g","d") Output=data.frame(Column1,Column2,Column3,Column4,Column5,Column6,Column7,Column8,Column9) If anyone know… Read More applying str_split_fixed function simultaneously across multiple columns in r

check if record exists in previous date and not in current date in the same table and return count of records matched and unmatched

Advertisements I am trying to get the count of records that were there in one date and also in another date. What would be the most efficient way? id date AB 6/11/2021 AB 6/11/2021 BC 6/04/2021 BC 6/04/2021 AB 6/04/2021 AB 6/04/2021 This should return True =2 (Ab is present in 04/21) and False=2 >Solution… Read More check if record exists in previous date and not in current date in the same table and return count of records matched and unmatched

Removing line breaks between 2 different character sequences

Advertisements I’m editing a csv file which contains hidden line breaks. When I apply the following php script, the line breaks are successfully removed from the entire file. $csvFileNew = str_replace(array("\r", "\n"), ”, $csvFileOld); But I only want to remove these line breaks from within certain sections of the file – between all occurrences of… Read More Removing line breaks between 2 different character sequences

Wait till first method is executed in all threads till execute second

Advertisements I have a small demo code where I have a Bean class and BeanRegister class. Bean class has two methods which are preInit() and postInit(). And BeanRegister is a thread class which has Bean class as a field. Here my code: public static void main(String[] args) { Bean beanA = new Bean(); BeanRegister beanRegister1… Read More Wait till first method is executed in all threads till execute second

trying to group_by and then summarize max and min – running into error for unambiguous format

Advertisements I have addresses that have duplicated information from Kingwood and Humble addresses. I am trying to combine these entries, preserving the the minimum first reported date, and the max last reported dates, using this code: df <- df %>% group_by(id, street) %>% summarise(firstReportedDate = min(as.Date(firstReportedDate))) %>% summarise(lastReportedDate = max(as.Date(lastReportedDate))) However, for some reason, id… Read More trying to group_by and then summarize max and min – running into error for unambiguous format

Unable to switch between environment in karate feature file

Advertisements As per KARATE documentatoion we should use System.setProperty() to set env in test case level, But that option is not working in karate 1.2.0 (Didn’t verify in previous versions) Feature Feature: Testing env changing Scenario: Reading base url of different env * print ‘Before changing env…—> ‘+ karate.env * print ‘Testing karate…’ * print… Read More Unable to switch between environment in karate feature file