Category : replace

I’m working on a project that deciphers the secret sentence. when I input apple.appleapple.pear.orange.lemon I want it to change into A.B.E.R.T I used split and replace to do it. However, I can’t find a way to change "apple" into A and "appleapple" into B at the same time because when I use replace(), appleapple changes ..

Read more

I have to lists: [‘gentleman-gnar’, ‘galactic-nasus’, ‘resistance-jayce’, ‘master-chef-tahm-kench’, ‘nutcracko’, ‘blood-moon-thresh’, ‘spellthief-lux’, ‘deep-sea-nami’, ‘ravenborn-leblanc’] [‘https://lolskinshop.com/wp-content/uploads/2015/06/splash-art-gentleman-gnar.jpg’, ‘https://lolskinshop.com/wp-content/uploads/2015/05/splash-art-galactic-nasus.jpg’, ‘https://lolskinshop.com/wp-content/uploads/2015/06/splash-art-master-chef-tahm-kench.jpg’, ‘https://lolskinshop.com/wp-content/uploads/2015/03/load-screen-nutcracko.jpg’, ‘https://lolskinshop.com/wp-content/uploads/2015/05/load-screen-spellthief-lux.jpg’, ‘https://lolskinshop.com/wp-content/uploads/2017/01/splash-art-deep-sea-nami.jpg’, ‘https://lolskinshop.com/wp-content/uploads/2015/04/splash-art-ravenborn-leblanc.jpg’] and i want to check if there is the name of the first list in the second list (for example: resistance-jayce is missing) and if its missing, i want to set a string (for example ..

Read more

I have a python dictionary that looks like this: states = { ‘AK’: ‘Alaska’, ‘AL’: ‘Alabama’, ‘AR’: ‘Arkansas’, ‘AS’: ‘American Samoa’, ‘AZ’: ‘Arizona’, ‘CA’: ‘California’…} for all states and territories in the US. My Dataframe looks something like this pandas data frame. I’ve tried code like: df[‘state’].replace(states) and df[‘state’].map(states) but both do not work. Source: ..

Read more

my current regular expression def rename_variables(self): with open(self.file_path, "r") as d: data = d.read() code = data variable_names = re.findall(r"(w+)(?=( |)=( |))", data) for i in range(len(variable_names)): obfuscated_name = generate_random_strings() code = re.sub(r"(?<=[^.])(b{}b)".format(variable_names[i][0]), obfuscated_name, code) return code This code replaces all occurances of the variable EVEN IN STRINGS when i am trying to avoid in ..

Read more

So I have a string inside of a file: C:dfolderprojectfolderFolder1Folder2Folder3Module.c What would be the best way to cut it just by counting backslashes from the end: So in this case we need to cut everything what is after 4th backslash when counting backward: Folder1Folder2Folder3Module.c I need something to do this since I always need to ..

Read more

I am trying to match the left and tight addresses (from separate tables) on a reference index (coClean) which I created with the following formula in #Python #JupyterNotebook import re def cleanAddress(series): return series.str.lower().str.replace(r"[a-zs,]","") df1["coClean"]=cleanAddress(df1["Address"]) This produces a coClean as a reference index. Address_x coClean Address_y 7 Pindara Bvd LANGWARRIN VIC 3910 73910 7 Pindara ..

Read more