I’m pretty new to programming and I’m starting with python Why is it that the ‘for’ loop is iterating over the list and not over the key of the dictionary? The intention is that the loop iterates over the list but I don’t understand why it’s happening if ‘for’ l…
Tag: python
Python Selenium – href specific output
I have been working on a project to pull specific href links from a site. Everything is working but I also want to be able to pull only specific data from href link. I haven’t been able to figure that part out. Here is the output I’m trying to get the output to look like this Answer Use regex Outp…
how do I match and find a vector in a Numpy array?
I have a Numpy array with size [2000,6].now I have an array with size [1,6] and I want to know which row of the main Numpy array is the same as this [1,6] array. if it exists in the main array, return the index of the row. for example row 1. but I do not want to use for loops
scipy.stats.cumfreq() isn’t the cumulative frequency I’m looking for
Reading a statistic book, I’m also training with Python. My book asks me to calculate the cumulative workforce and the cumulative frequency of a simple list of jobs. Secteur Nombre d’emplois Agriculture 21143585 Construction 35197834 Industrie 69941779 Fabrication 64298386 Services 368931820 I wro…
Identifying empty list in JSON data in Python
I have a json data set I’m trying to insert into a database. To do so, I need placeholders “” for non-existent data. In the example below, if there’s no email address, I need the insert statement to be (….,”boo”,….) instead of (….,”me@mail.com”…
How to plot hour:min time in ISO 8601 time format?
I am trying to plot temperature data points according to their time recording. Note: as you have mentioned t is represented without hour, the reason is that temp been collected in hour:second. t is a string representing the date and time in ISO 8601 format (ref: datetime.datetime.isoformat()) and temp is a fl…
Python ignore already replaced string / replace string not already replaced
Is there a way to identify an already converted/replaced string and not allow it to replace again? This give result as My {first_{family_name}} is not my {family_name} I want result like: My {first_name} is not my {family_name}. Answer You can’t ignore it. Python is searching for ‘name’, and…
Numpy rounding issue
Can someone explain to me why is numpy round acting strange with this exact number rounding: It’s obvious that the first number is not rounded well, any ideas? EDIT: Since I’m focused here on the precision, not so much on the performance, I’ve used python round function to solve this problem…
How to extract words with a repeated letter not count one specific? python
I have a multiple word file where the same letters appear multiple times. I’ve already learned to catch these words. Now I would like the words with the letter “a” not to be counted by the script. My file.txt: my code: result: I try to make that only “a” can repeat in a word, if …
Subtype Generator with fixed type variables
Say I have a program with several generator functions that all have the return type Generator[<type>, <type2>, None] and I want to make an alias SimpleGenerator[<type>, <type2>] that is then expanded to the previous. So for example could be written I imagine the code might look somethi…