6

I was testing a simple connection from an Amazon Redshift database to my local database using PostgreSQL. I wrote a query to obtain a table from the database, and converted that to a pandas DataFrame. Now, whenever I want to apply some functions on the DataFrame objects, I get the following error. I have tried several times to modify it, and looked up a lot of solutions, but can't seem to work around with it.

cur.execute("QUERY for PostgreSQL")
rows = cur.fetchall()
print("Received as rows")
col_names = []
for i in cur.description:
    col_names.append(i[0])
df = pd.DataFrame.from_records(rows, columns = col_names)
df.values()

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-16-8e9714b76ea1> in <module>()
---->  df.values()

TypeError: 'numpy.ndarray' object is not callable
10
  • 6
    remove (), need only df.values Commented Sep 20, 2017 at 8:39
  • @jezrael Thanks for the prompt reply! How can I use any other functionalities on my dataframe objects? For example, I want an aggregate of the third column but when I use .mean or .aggregate, it doesn't do that. Also, when I do .describe(), it uses the first column, instead of the third column. How can I approach this? Commented Sep 20, 2017 at 8:45
  • I think it is a bit broad, the best is create some data sample and desired output. Commented Sep 20, 2017 at 8:51
  • But I believe docs should help. Commented Sep 20, 2017 at 8:52
  • @jezrael but it doesn't talk about how I can use just one of the columns to get the .describe() to work or mean() over that one column. Commented Sep 20, 2017 at 9:01

1 Answer 1

15

As @jezrael pointed out in the comments, df.values is not a function, so you don't need to call it. Just use df.values instead of df.values().

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! However, if I want to do a .describe() on my third column of the dataframe, how can I do that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.