Python Forum
TypeError: 'DataFrame' object is not callable using Pandas in Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: 'DataFrame' object is not callable using Pandas in Python
#1
Hello to everyone, I have a question…

I’ve programmed these:


# Dependencies
import pandas as pd
from numpy import where
from matplotlib import pyplot

# Load Data
names = [“Frequency”,”Comments Count”,”Likes Count”,”Text nwords”]

dataset = pd.read_csv(“Posts.csv”, encoding=”utf-8″, sep=”;”, delimiter=None,
names=names, delim_whitespace=False,
header=0, engine=”python”)

X = dataset.values[:,0:2]
y = dataset.values[:,3]
# Explore Data
print(dataset.shape)
print(dataset.head(10))
print(dataset.describe())
print(dataset.dtypes)

X,y = dataset(n_samples=100, n_features=4, n_informative=4, n_redundant=0, n_clusters_per_class=1, random_state=4)

# create scatter plot for samples from each class
for class_value in range(3):
# get row indexes for samples with this class
row_ix = where(y == class_value)
# create scatter of these samples
pyplot.scatter(X[row_ix, 0], X[row_ix, 3])
# show the plot
pyplot.show()
I’m getting this error :

Traceback (most recent call last):

File “C:/Users/USER/pythonProject/main.py”, line 44, in

X,y = dataset(n_samples=100, n_features=4, n_informative=4, n_redundant=0, n_clusters_per_class=1, random_state=4)

TypeError: ‘DataFrame’ object is not callable
Any ideas? What can I do?

I think the problem is about the #load data.. How can I insert my own dataset?

Maybe I confuse the Dataset (as a variable) with the Dataset as a function.

Thank you in advance!!
Reply
#2
(Sep-02-2021, 03:19 PM)sofiavlachou Wrote: Maybe I confuse the Dataset (as a variable) with the Dataset as a function.
which dataset function do you refer to?

In your code dataset is DataFrame object and it's not callable.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Merge htm files with shutil library (TypeError: 'module' object is not callable) Melcu54 7 3,385 Mar-09-2025, 04:25 PM
Last Post: Pedroski55
  Most efficient way to roll through a pandas dataframe? sawtooth500 2 1,129 Aug-28-2024, 10:08 AM
Last Post: Alice12
  docx file to pandas dataframe/excel iitip92 1 2,577 Jun-27-2024, 05:28 AM
Last Post: Pedroski55
  I am getting this TypeError: 'TreasureMap' object is not subscriptable. makilakos 2 1,231 May-25-2024, 07:58 PM
Last Post: deanhystad
  TypeError: cannot pickle ‘_asyncio.Future’ object Abdul_Rafey 1 2,706 Mar-07-2024, 03:40 PM
Last Post: deanhystad
  error in class: TypeError: 'str' object is not callable akbarza 2 1,738 Dec-30-2023, 04:35 PM
Last Post: deanhystad
  Python Alteryx QS-Passing pandas dataframe column inside SQL query where condition sanky1990 0 1,371 Dec-04-2023, 09:48 PM
Last Post: sanky1990
Bug TypeError: 'NoneType' object is not subscriptable TheLummen 4 3,585 Nov-27-2023, 11:34 AM
Last Post: TheLummen
  TypeError: 'NoneType' object is not callable akbarza 4 13,948 Aug-24-2023, 05:14 PM
Last Post: snippsat
  [NEW CODER] TypeError: Object is not callable iwantyoursec 5 5,595 Aug-23-2023, 06:21 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020