figure - grocery dataset transactions the first observation that we make from this dataset is that it is not available in completely structuredeasy-to-analyze format this limitation will mean that the first thing we will have to do is to write custom code that will convert the raw file into data structure we can use since we have done most of our analysis until now using the pandas dataframewe will convert this data into similar data structure the following code snippet will perform the conversion for us grocery_items set(with open("grocery_dataset txt"as freader csv reader(fdelimiter=","for iline in enumerate(reader)grocery_items update(lineoutput_list list(with open("grocery_dataset txt"as freader csv reader(fdelimiter=","for iline in enumerate(reader)row_val {item: for item in grocery_itemsrow_val update({item: for item in line}output_list append(row_valgrocery_df pd dataframe(output_listin [ ]grocery_df shape out[ ]( the conversion gives us dataframe of dimension (num_transactiontotal_items)where each transaction row has columns corresponding to its constituent items as for examplefor row in figure - we will have the column for whole milk as and the rest of columns will be all although this data structure is sparsemeaning it has lot of zerosour framework that extracts association rules will take care of this sparseness before we proceed to building association rules on our datasetwe will explore some salient features of our dataset we already know that we have , total transactions and total of items in the dataset but what are the top items that occur in the dataset and how much of the total sales they account for we can plot simple histogram that will help us extract this information in [ ]total_item_count sum(grocery_df sum()print(total_item_countitem_summary_df grocery_df sum(sort_values(ascending falsereset _index(head( = item_summary_df rename(columns={item_summary_df columns[ ]:'item_name'