以下代碼(當然)僅保留按'Date'排序的行中第一次出現的'Item1'。有關我如何能夠保持它的任何建議,比如前5次發生?保持N首次出現
## Sort the dataframe by Date and keep only the earliest appearance of 'Item1'
## drop_duplicates considers the column 'Date' and keeps only first occurence
coocdates = data.sort('Date').drop_duplicates(cols=['Item1'])
也許'[5]'? – Fabricator