Skip to content
Advertisement

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 in terms of

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[‘date’][0] < datetime.date(2022, 4, 22) gave me ‘True’ However, when I wanted

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 string time is

How to create dictionary from multiple dataframes?

I have a folder with several csv files. Example of the dataframes from csv files in directory: I need to make a function that accepts route to file directory and return sites frequency dictionary (one for all sites in file directory) with unique sites names the following kind: {‘site_string’: [site_id, site_freq]} For our examle it will be: {‘vk.com’: (1, 2),

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

ValueError: Could not interpret input ‘0’ with Seaborn?

I’m using the Kepler exoplanet dataset. After loading it, and running a simple transpose() on it, in order to get the rows as columns, I try a seaborn boxplot, as follows: This returns: I also attempted this: and got a KeyError: ‘0’ instead. What am I doing wrong? As far as I can tell, I’m doing the exact same thing

Advertisement