[Solved] write the folder path for it [closed]

@Monso, as per your provided inputs, expected outputs in problem & in comments, I’ve written the code to solve your problem. In my case: Input directory: C:\Users\pc-user\Desktop\Input Output directory: C:\Users\pc-user\Desktop\Output And I have 3 file A.txt, B.txt & C.txt inside Input directory with contents as follows. You’ve to use your own paths as you’ve mentioned … Read more

[Solved] The second root of a number is up to four digits without decomposing it

If you’re printing only 4 decimals and you don’t want the number rounded that means you want the decimals truncated and regular formatting methods don’t provide facilities for that. You can easily achieve that if you pre-process your number as: def truncate_number(number, decimals): factor = 10.0 ** decimals return int(number * factor) / factor num … Read more

[Solved] Pandas Python: KeyError Date

This looks like an excel datetime format. This is called a serial date. To convert from that serial date you can do this: data[‘Date’].apply(lambda x: datetime.fromtimestamp( (x – 25569) *86400.0)) Which outputs: >>> data[‘Date’].apply(lambda x: datetime.fromtimestamp( (x – 25569) *86400.0)) 0 2013-02-25 10:00:00.288 1 2013-02-26 10:00:00.288 2 2013-02-27 10:00:00.288 3 2013-02-28 10:00:00.288 To assign it … Read more

[Solved] how to find the words that are likely to follow the single word in large string in python .?

You can use a regex to look for words that follow the word python, for example >>> import re >>> re.findall(r’Python (\w+)’, s) [‘is’, ‘has’, ‘features’, ‘interpreters’, ‘code’, ‘is’, ‘Software’] Since this list may contain duplicates, you could create a set if you want a collection of unique words >>> set(re.findall(r’Python (\w+)’, s)) {‘Software’, ‘is’, … Read more

[Solved] Finding regular expression with at least one repetition of each letter

You could find all substrings of length 4+, and then down select from those to find only the shortest possible combinations that contain one of each letter: s=”AAGTCCTAG” def get_shortest(s): l, b = len(s), set(‘ATCG’) options = [s[i:j+1] for i in range(l) for j in range(i,l) if (j+1)-i > 3] return [i for i in … Read more

[Solved] Write application for analysis of satellite imagery of dates from cvs file

Try and see! Here is a request for imagery of the O2 Arena on the river in London for an image from January 2017: curl “https://api.nasa.gov/planetary/earth/imagery/?lon=0&lat=51.5&date=2017-01-01&cloud_score=True&api_key=DEMO_KEY” Here is the result: { “cloud_score”: 0.047324414226919846, “date”: “2017-01-17T10:52:32”, “id”: “LC8_L1T_TOA/LC82010242017017LGN00”, “resource”: { “dataset”: “LC8_L1T_TOA”, “planet”: “earth” }, “service_version”: “v1”, “url”: “https://earthengine.googleapis.com/api/thumb?thumbid=a286185b3fda28fa900a3ce43b3aad8c&token=206c7f1b6d4f847d0d16646461013150” If you paste the URL at the … Read more

[Solved] Race Condition when reading from generator

I think you need to do something like this # Print out predictions y = regressor.predict(input_fn=lambda: input_fn(prediction_set)) # .predict() returns an iterator; convert to a list and print predictions predictions = list(itertools.islice(y, 6)) print(“Predictions: {}”.format(str(predictions))) I found it from the boston tutorial: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/input_fn/boston.py 0 solved Race Condition when reading from generator

[Solved] Check if letters in list add up to a variable

Not sure why your question is drawing so much bad attention. permutations are what you need: from itertools import permutations def is_perm(letters,word): for p in permutations(letters): if ”.join(p) == word: return True return False letters = [“a”, “c”, “t”] word = ‘cat’ print is_perm(letters,word) Letters may of course be any list of strings, not just … Read more

[Solved] How to merge two list of list in python

You may achieve this using itertool.chain() with list comprehension expression as: >>> a=[[1,2,3],[4,5,6]] >>> b=[[5,8,9],[2,7,10]] # v join the matched sub-lists # v v your condition >>> [i + list(chain(*[j[1:] for j in b if i[1]==j[0]])) for i in a] [[1, 2, 3, 7, 10], [4, 5, 6, 8, 9]] solved How to merge two … Read more

[Solved] Django: how to get order_detail_data as per order_id

If you are using raw queries, then you just need to merge the data. Something like this should work, def merge_order_data_and_detail(orders, details): “””Group details by order_id and merge it in orders.””” # create dictionary key:order_id value:[order_detail_data] dic = {} for d in details: if d[‘order_id’] not in dic: dic[d[‘order_id’]] = [] dic[d[‘order_id’]].append(d) # iterate orders … Read more