What is the Django query for this? DB data – I only need record that contain “1.2.3” values not like – (“Cat 1.2.3” or “1.2.3-XY2” or any such value). And pattern “1.2.3” can be anywhere in column where column value can have comma separated values to…
Tag: python
How to create a Dockerfile for streamlit app
I am aiming to deploy a web-app written with Sreamlit, I can run this on my local machine by running streamlit run Home.py in my command line. However, I’m not sure how to create the docker file. Any advice? Answer In order to Dockerise your app you need two files: Dockerfile : describes the image struc…
Improve the speed of code with if else statements
I am working on building a classs. But I realized that one part is extremly slow. I believe it is this part below, because when I call it, it takes couple of minutes which is too long. How can the speed of the function be improved? Not sure how the code can be improved to increase speed. There is a
DNS Packet IP Address Structure
I have been writing a python program that builds a packet and sends a reverse DNS lookup request to a DNS server. I have a problem the IP address is stored in hex in a way that is difficult to understand. In the hex field it has the number of each iteration with a 3 in front of it, so
How to adjust the measurement of cells in .csv/.xlsx file?
How can I adjust the measurement of the cells in the .csv/.xlsx file? Let’s say I wanted the cell of the first entry to be 25px or a similar measurement. Answer You can access to workbook and active sheet through ExcelWriter:
How to enter new rows in a dataset by keeping same index
I am trying to enter into the following dataset: the rows: As you could see, the dataset created with the first chunk of code turns a with the first row marked with index 1. To maintain it, I used the following code to add two further rows where the new rows are added as follows at the last one of
Python hangman Game explaination
I’m having problems wrapping my head around this for loop code. which was part of a Udemy course online and the teacher’s code for the hangman project. This part I understand as we are casting the number of letters in the chosen word into an underscore. This is the part I just do not understand. l…
how to check if a number exists between two columns of pandas dataframe & replace a value
I have a data frame and integer like this: I want to check if the given number(17) is in between the min & max column of any row. If the number is between min & max columns, then the max column value in that row should be replaced by that integer. In the example, the integer 17 exists between 13
Python – Find distinct domains inside a list of dictionaries
I have a list (with dictionaries inside) and I want to know how many different domains are inside it. I have something like this: The desired result would look like this: Or maybe just: Both would be OK, so whatever is easier or faster I guess. I think I could use Regex for this, but maybe there are more pyth…
Join to dataframes based on index where the second dataframe has repeated indexes related to the first dataframe
I have two data frames where first dataframe has index starting from zero. The second dataframe has repeated indexes starting from zero. I want to to join the two dataframes based on their indexes. First dataframe is like this The second dataframe is I want to join these two dataframes based on index i.e the …