DevilsKiss
DevilsKiss

Reputation: 46

Object has no attribute

I am learning python/numpy. I followed instructions but somewhat code does not working.

    import numpy
    import os
    desktop = os.path.normpath(os.path.expanduser("~/Desktop"))
    import pandas
    x = pandas.read_csv('Desktop/numpy exc/2dcsv.csv',header = None)
    print(type(x))
    print(x.info)
    y = x.as_matrix()
    print(y)

AttributeError: 'DataFrame' object has no attribute 'as_matrix'

Upvotes: 2

Views: 347

Answers (2)

BioGeek
BioGeek

Reputation: 22887

pandas.DataFrame.as_matrix() is deprecated. Use pandas.DataFrame.to_numpy() instead.

Upvotes: 3

Baran Bursalı
Baran Bursalı

Reputation: 360

Instead of x.as_matrix() try x.to_numpy().

In panda's documentation it says:

Deprecated since version 0.23.0: Use DataFrame.values() instead.

Upvotes: 4

Related Questions