0

I have imported data for basket analysis, where each row of my data represents a shopping basket. I want to import this into a list of tuples, but when I do this I get lots of NaN values, as each list is the length of the maximum basket.

How can I remove these NaN values so I can see each basket correctly?

[['ItemA', 'ItemB', 'ItemC', 'ItemD', nan, nan, ...],

Here is my code so far:

import pandas as pd
data = pd.read_csv('basket_analysis_sample_2_small.csv')
data = data.values.tolist()
Ben P
  • 3,267
  • 4
  • 26
  • 53
  • Hi @BlackThunder I've read through both posts, but I don;t see how I can apply to my situation. I am working with strings, not numbers, and I can't drop rows that contain NaN, as almost all do. How can I trim them down? – Ben P Aug 28 '19 at 14:11
  • Please edit your question then, and elaborate how is your question different. – Nouman Aug 28 '19 at 14:14

0 Answers0