Skip to content

Tag: pandas

Get Top N items per month in pandas

I have the following dataframe (which is a pretty reduced sample from my original one). I’m trying to get the top 2 ids for each year AND month. So, for example, the idea was to obtain the below df. My main problem here, is to get the Top n along with the dates, because the nlargest method applies to a

How to combine dataframes based on index column name

Hello I am new to python and I have 2 dfs and a list of tickers and i would like to combine the 2 dfs based on a list of tickers. My second df had the tickers imported from an excel sheet and so the column names in the index are in a different order, I am not sure if

Expecting integer values in calculation, but getting

I am working on implementing an ID3 algorithm in python. In order to get past the first step I need to calculate the information gain per column. The comments are self-explanatory. The issue that I am trying to resolve is From the simple program shown below. The Test set for ID3.csv The Training set for ID3.c…