Skip to content

Tag: datetime

Add trend line to datetime matplotlib line graph

I have a pandas dataframe df: And I can plot this easily using plt.plot: But now I want to add a trendline. I tried using some answers: How can I draw scatter trend line on matplot? Python-Pandas Which doesn’t work: Then I found the following question and answer: TypeError: ufunc subtract cannot use ope…

Add a filter to timeseries pairs

I have a time series plc tag data as below with values in ‘1’ or ‘0’ Using below code I can get the output Output But my requirement is, I only want to query going back 25 hours, so I add a predicate: But this returns the error: Msg 209 Level 16 State 1 Ambiguous column name ‘dat…

Creating a series of Quarters

Let say I have a date Now starting from mydate, I want to create an array of 10 quarters e.g. 2020-Q1, 2020-Q2, … [total 10 values] Is there any direct way to achieve this? In R, this is pretty straightforward, as I can use seq() function to generate the same. Any pointer will be very helpful Answer it …

Sort the list of tuples in python

I have tuples like this these are the coins and its expiries. The date is in string format, so the arrangement is wrong. so i have changed the format to date and tried to arrange. I have tried the below code. and the result is as expected as sorted. now when i want back in older format which i mentioned