Object has no attribute

Viewed 187

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'

2 Answers

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.
Related