Skip to content
Advertisement

Tag: string

Regex: allow comma-separated strings, including characters and non-characters

I’m finding it difficult to complete this regex. The following regex checks for the validity of comma-separated strings: ^(w+)(,s*w+)*$ So, this will match the following comma-separated strings: Then, I can do the same for non-characters, using ^(W+)(,s*W+)*$, which will match: I would like to create a regex which matches strings which include special characters, and hyphens and underscore, e.g. foo-bar,

Draw a simple box around a string

I’m trying to learn python, and one of the “tasks” asks me to draw a box around a string. For some reason, I can’t come to a solution. This is supposed to be super basic so we can’t use functions and loops etc. Here’s the task: (I’m stuck on question 2) Load a string via the input () function, and

Flipping a binary in a string

I am new to python and coding in general. So what I am trying to achieve is to flip each bit in a binary string (for eg. if I input ‘110’ the output should be ‘001’). I specifically need to use the while loop and I need to define it as a function. Here is what I’ve tried so far:

Finding a specific string in a Dataframe column

I’m trying to retrieve one row of data from my Dataframe created from a csv file accessed via URL. I’m using… df1[‘Statistic Element’].str.contains(‘Mean rainfall’) …to determine the row containing the data I require however python does not recognize the .str element of the dataframe? DF1.info() The code works fine using a test dataframe so I’m wondering if there is a

Call many python functions from a module by looping through a list of function names and making them variables

I have three similar functions in tld_list.py. I am working out of mainBase.py file. I am trying to create a variable string which will call the appropriate function by looping through the list of all functions. My code reads from a list of function names, iterates through the list and running the function on each iteration. Each function returns 10

Advertisement