Skip to content

Tag: python

Pandas apply/lambda on multiple columns

I have a simple script transforming data in a dataframe: The above seems to work fine. I have tried rewriting the last two lines to: However, this fails and gives a value error: I am trying to understand why it can’t be used in the above way. My pad_value function seems clunky – I wonder if there …

How to understand the error in my Python program

I’m trying to code a program that prints the factors of a number, just as shown in the attached image, but the outcome is totally not what I’m expecting. (I just want the code to return factors of the specified number.) What am I doing wrong and what is the correct way of doing it? Code: Output: A…

Cumulative of last 12 months from latest communication date?

I’m looking at counting the number of interactions grouped by ID in the last 12 months for each unique ID. The count starts from the latest date to the last one grouped by ID. Output is something like the below. How can I achieve this in Pandas? Any function that would count the months based on the date…

How run an mp4 in Tkinter?

I have been trying to run an mp4 in Tkinter and have been getting an error message about a couple line errors in –main–.py, and runpy.py. I’m a newbie and this is confusing me because I’ve been spending hours trying to fix this. I am also having a problem in the file path for my video,…

Change bubble size in altair without changing font size

I am trying to create a altair bubble chart. The sample code and sample dataframe is below: I want the size of the bubble based on Market_cap and put names of companies alongside. The problem is font size of names is also changing as per the bubble size. How can this I create this bubble chart with different …