Skip to content
Advertisement

Tag: string

Using If statement with string values in Python

I have a df where column A is either blank or has a string in it. I tried to write the if statement (all columns are strings) below. Basically, if there is something (any value) in df[A], then the new column value will be a concatenation of columns A, B and C. If there is no value in df[A], then

Tuple comparison in function

I am wondering why my comparison returns False and not True although ‘a’ == ‘a’. Output: False Answer It’s because you are using *values rather than values in your function definition When you use the special syntax *args in a function, args will already come back as a tuple, where each arg is an element of the tuple. So for

Regex Pattern in Python for special charaters

I asked a similar question a few days ago on here and it was great help! A new challenge I wanted build is to further develop the regex pattern to look for specific formats in this iteration, and I thought I have solved it using regex 101 to build/test a regex code but when applied in Python received ‘pattern contain

Advertisement