python : How to make a combination according to the count of elements?

import random import itertools method_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'] random.shuffle(method_list) per = list(itertools.permutations(method_list, 4)) for ele in per: ss = set(list(ele)) if len(ss) == 4: if not ('h' in ss and 'i' in ss): result.append(ss) I want to make a total of 250 random combinations by taking 4 elements … Read more

How would I extract any word after second hyphen in pandas

Below is my DF df = pd.DataFrame({'A': ['a', 'b', 'c', '0'], 'B': ['0xF188-abc-cde', '0xF188-abc-abcde', '0xF188-abc-1234', '0xF188-abc-tu231er']}) Now I want to add NEW column “EXTRACT” which is an extraction of column ‘B’ after second hyphen. Below is the Expected Column. df= pd.DataFrame({'A': ['a', 'b', 'c', '0'], 'B': ["0xF188-abc-cde", '0xF188-abc-abcde', '0xF188-abc-1234', '0xF188-abc-tu231er'], 'Extract':['cde', 'abcde', '1234', 'tu231er']}) Answers: … Read more

How to get python Script output in Text file ,without overwriting current one text file

Hello I have written python code which run by task scheduler. This code delete the folder which are older than 5 days. code is working fine but I took output of this code in log text file. whenever code run existing log file overwritten. I want see every schedule log , that’s not possible now.
How I can get output of code in different file every time or in same file without overwriting data.