Skip to content

Tag: python

Python create lists conditionally from txt file

I have a txt file with this structure of data: 3 100 name1 200 name2 50 name3 2 1000 name1 2000 name2 0 The input contains several sets. Each set starts with a row containing one natural number N, the number of bids, 1 ≤ N ≤ 100. Next, there are N rows containing the player’s price and his name

Python equality statement of the form a==b in [c,d,e]

I just came across some python code with the following statement: It turns out that: Am I right in assuming that a==b in [c,d,e] is equivalent to (a==b) in [c,d,e] and therefore only really makes sense if [c,d,e] is a list of True/False values? And in the case of the code I saw b is always in the list [c,d,e]…

iterrows() , if statement and assigning string to new column

I want to add some data to a dataframe to analyse stock price movements. I want to check, if a row is the narrowst range in 7 bars. Unfortunately I seem to be able to run through the df array and perform a basic check. But I can´t assign a string to a column when the If-Statement fulfilled.Any ideas what´s

python: convert parenthesis to bracket

I need to check if longitude, latitude is in polygon in Python 3. The code below works, but I have a problem putting data from variable. but my data are like this (I get data from json file with json.load) How can I pass data from coordinates[0] to polygon which requires ( ) instead of [ ] and this doesn&#821…

How to parse a string in argparser during execution

I want to create a mini shell, so after i run my file, With whatever arguments I add, I then just constantly take input like a normal shell, So I am just doing simple while True: command = input(), but these commands may take flags as well so stuff like However I can’t really parse these the same way as