Dataframe’s with strange structure with variables in even columns

I’m a beginner with python in combination with pandas, and I understand the basics. But I received a couple days ago 3 strange datasets in excel. As image below: import pandas as pd dfinput = pd….

Find how many numbers two numbers have in common

So I’m trying to make a program that tells the user how many numbers both inputted numbers have in common FOR EXAMPLE: if inputted n1 = 765 and n2 = 572 then the program returns 2 because both numbers …

Overload function in all subfunctions in scope

Let’s say that I want to overload a standard function with a customized version, I can simply write original_function_name = customized_function For example I can do: def custom_print(s): print(f’!…

Asyncio stream process data with pipe between two subprocesses

Hello I can’t find a solution for the example here. I found https://stackoverflow.com/a/36666420/6089311 but there is no stream reading. I’d like to run two subprocesses independent of python program (…

Replacing values using dictionary

What are the reasons why are regex replacment doesn’t work? I have tried ensuring no excess spaces. df.column 0 Test_With_Him 1 And_another option with him 2 and_another reason with her …

sum the elements of 2 NumPy arrays

import numpy as np n1=np.array([10,20,30,40,50,60]) n2=np.array([50,60,70,80]) np.sum([n1,n2]) ValueError Traceback (most recent call last)

How to iterate over a list once only in a nested loop in Python

I intend to send message to many numbers, but this is my code and issue (code is made shorter and required lines are here): msg = ‘test message’ phone_numbers = [‘+989111111111’, ‘+989111111112’, ‘+…

Kafka with python: How to send topic to postgreSQL?

I am urged to use Kafka with python. Moreover, I need to develop a very simple producer-consumer application that reads metrics from a device in real-time and then publishes them to a topic ‘metrics’ …

Merging pandas columns into a new column

Suppose I have a dataframe as follows earningspersharebasic earningsPerShareBasic 2019 -0.19 NaN 2018 NaN 4.00 2017 …

pandas groupby column to list and keep certain values

I have the following dataframe: id occupations 111 teacher 111 student 222 analyst 333 cook 111 driver 444 lawyer I create a new column with a list of the all the …