Skip to content

Tag: python

Python: class and object

I have no idea why when i run my code it returns wrong value. These are the assertions that I use to test my code when i print out my code i get a correct result for weeks and hours, buts for days I always get the wrong result. If anybody know could youplease help me. Answer I couldn’t figure

Pandas array filter NaN and keep the first value in group

I have the following pandas dataframe. There are many NaN but there are lots of NaN value (I skipped the NaN value to make it look shorter). I would like to filter all the NaN value and also only keep the first value out of the NaN (e.g. from index 27-29 there are three values, I would like to keep

using PIL to draw equal lines

what I’m trying to do is to draw horizontal lines in PIL of equal size. but my problem is that when I’m trying to fill the image it isn’t full. This is what I’m getting when it should be fully equal. There shouldn’t be any white. It also should work with more or less colors Code …

Days between dates into minimum non-date measurement

I have a column that represents the number of days from an event until today. I am trying to figure out a way to represent this as a string such that it shows the rounded number of days / weeks / months / years. However, I would like it to choose “D”/”W”/”M”/”Y”…