I have a csv file with company software details along with installed dates. I am reading the csv file using pandas in a dataframe. Below is the sample data containing two different software:
software_id software_name installed_date software_version
8331 Intel(R) Graphics Media Accelerator Driver 2009-05-23 0:00 8.15.10.2008
8331 Intel(R) Graphics Media Accelerator Driver 2010-09-15 0:00 8.15.10.2008
8331 Intel(R) Graphics Media Accelerator Driver 2009-12-27 0:00 8.15.10.2008
8332 Wireless Switch Utility 2009-12-22 0:00 4.3.1400.0
8332 Wireless Switch Utility 2010-11-22 0:00 4.3.1400.0
8332 Wireless Switch Utility 2011-01-25 0:00 4.3.1400.0
So from the above data I just need to keep one row with the latest date from each software code. For example, the output of the above file should be:
software_id software_name installed_date software_version
8331 Intel(R) Graphics Media Accelerator Driver 2010-09-15 0:00 8.15.10.2008
8332 Wireless Switch Utility 2011-01-25 0:00 4.3.1400.0
How can I choose the set of rows for one software code and remove all rows but the one with the latest date and then move to the next software code until the file only has one entry per software code. I cannot hardcode the software_id to check as there are thousands of them.
My logic is to read and store the first software_id and installed_date in two variables and start reading the file line by line. Next line will check if the software_id matches the one stored in the variable and then compare the date and store the latest one in the variable. When the software_id does not match the stored software id then it means that new software_id block has started. It will then store the previous values in the dataframe and start executing next blocks and so on.
FYI - I am a pandas noob.
Thanks for all the help.