How to fix AttributeError: 'Series' object has no attribute 'to_numpy'

Refresh

6 days ago

Views

13 time

0

This is my output

def load_data(self):
    """
    Load data from list of paths
    :return: 3D-array X and 2D-array y
    """
    X = None
    y = None
    df = pd.read_excel('data/Data.xlsx', header=None)
    for i in range(len(df.columns)):
        sentences_ = df[i].to_numpy().tolist()
        label_vec = [0.0 for _ in range(0, self.n_class)]
        label_vec[i] = 1.0
        labels_ = [label_vec for _ in range(0, len(sentences_))]
        if X is None:
            X = sentences_
            y = labels_
        else:
            X += sentences_
            y += labels_
    X, max_length = self.tokenize_sentences(X)
    X = self.word_embed_sentences(X, max_length=self.max_length)
    return np.array(X), np.array(y)

This is my code with pandas library as pd. When I run in Google Colab I get a AttributeError: 'Series' object has no attribute 'to_numpy' . Please help me!!!

0 answers