'We are getting error as : TypeError: 'NoneType' object is not subscriptable what should we do

def split_data(data):
    print("Splitting data...")
    features = data[:,1]
    labels = data[:,0]
    training_data, test_data, training_labels, test_labels = train_test_split( features, 
    labels, test_size=0.3, random_state=0)
    print(labels)
    print("flag 3: splitted data")
    return training_data, test_data, training_labels, test_labels

And here we are getting error as : in split_data(data) 1 def split_data(data): 2 print("Splitting data...") ----> 3 features = data[:,1] 4 labels = data[:,0] 5 training_data, test_data, training_labels, test_labels = train_test_split( features, labels, test_size=0.3, random_state=0)

TypeError: 'NoneType' object is not subscriptable

Here type of data is array, we have tried data as dataframe also but it didn't work,What should we do?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source