Josh
Josh

Reputation: 11

How to select a data from a subset

I make an array of Customer Name and Segment to know this customer belongs to which segment. However, I am trying to select the customer name only in the array of customer name and segment as the X data for my scatter plot graph, using the customer name as X and profit as Y.

Therefore I used this code :

customer = store[["Customer Name","Segment"]].values
for i in range (0,10378):
    name = []
    name[:,i] = customer[:,0]

It returns me this instead :

TypeError: list indices must be integers or slices, not tuple

Upvotes: 0

Views: 52

Answers (1)

Saleem Ali
Saleem Ali

Reputation: 1383

Issue is here

name[:,i] = customer[:,0]

in list slicing list[start:end:steps] start, end, steps must be integer. but you have constructed the tuple by using comma(,) in before i and 0

Correct syntax should be:

name[:i] = customer[:0]

UPDATE

Also this line of code just shrinking the name list to an empty list. wondering what's the purpose you have with this line of code

Upvotes: 1

Related Questions