Skip to content

Tag: pandas

Plotting time series directly with Pandas

In the above dataframe, all I want to create a line plot so that we have info on trends per year for each of the columns. I’ve read about pivot-table on related posts, but when I implement that, it says there are no numbers to aggregate. I don’t want to aggregate something. I just need the y-axis …

Pandas datetime filter

I want to get subset of my dataframe if date is before 2022-04-22. The original df is like below df: I checked data type by df.dtypes and it told me ‘date’ column is ‘object’. So I checked individual cell using df[‘date’][0] and it is datetime.date(2022, 4, 21). Also, df[&#…

Index must be DatetimeIndex when filtering dataframe

I then have a function which look for a specific date (in this case, 2022-01-26): Which returns: When I then try to look for only times between 09:00 and 09:30 like so: I get the following error: Full code: What am I doing wrong? Answer between_time is only valid if your index is a DateTiimeIndex As your stri…

loop over rows of csv and put inside code

I am trying to read 5 columns from a 6 column csv data and use each row in a formula and itarete for all the rows. the file is csv file is something like this with hunderds of rows when I put values by hand it works all in well. However, when I put the df columns to do it