Adding comment as answer since it solved the problem. count is somewhat of a protected keyword in DataFrame API, so naming columns count is dangerous. In your case you could circumvent the error by not using the dot notation, but bracket based column access, e.g.

info["count"]
Answer from LiMuBei on Stack Overflow
🌐
Mbse-capella
forum.mbse-capella.org › scripting
Object has no attribute '_get_object_id' - Scripting - Eclipse Capella Forum
May 23, 2022 - requirements Packages (pkg): def get_reqPKG3(self): “”" “”" return create_e_list(self.get_java_object().getOwnedRequirementPkgs(), RequirementPkg) I do obtain a java list containing the requirements packages successfully: print(se.get_physical_architecture().get_reqPKG3()) → The...
🌐
Stack Overflow
stackoverflow.com › questions › 57502975 › py4j-serialization-attributeerror-dict-object-has-no-attribute-get-object
python - Py4J Serialization: AttributeError: 'dict' object has no attribute '_get_object_id' - Stack Overflow
August 14, 2019 - Using Py4J, I am not able to parse a Python dictionary object into the underlying JVM instance. I have written a PySpark code where I'm running a UDF/lambda function on a RDD. My goal is to run a ...
Discussions

python - Spark join throws 'function' object has no attribute '_get_object_id' error. How could I fix it? - Stack Overflow
I am making a query in Spark in Databricks, and I have a problema when I am trying to make a join between two dataframes. The two dataframes that I have are the next ones: "names_df" which has 2 co... More on stackoverflow.com
🌐 stackoverflow.com
python - "AttributeError: 'function' object has no attribute 'get'" in SQLAlchemy ORM Object contructor - Flask - Stack Overflow
EDIT Found my error! Leaving problem description as is, but appending answer bellow. In my registration function, I want to create a new User object. I've defined a User Table like this: class User( More on stackoverflow.com
🌐 stackoverflow.com
AttributeError: 'numpy.int64' object has no attribute '_get_object_id'
AttributeError: 'numpy.int64' object has no attribute '_get_object_id' More on github.com
🌐 github.com
2
May 19, 2021
AttributeError: 'DataFrame' object has no attribute '_get_object_id'
Using the Zeppilin notebook server, I have written the following script. The initialization is taken from the template created in glue, but the rest of it is custom. I'm getting the error: ``` Att... More on repost.aws
🌐 repost.aws
3
0
October 11, 2018
🌐
Hugging Face
discuss.huggingface.co › beginners
Error with BertTokenizerFast: AttributeError - 'function' object has no attribute 'get' - Beginners - Hugging Face Forums
October 8, 2023 - Hey everyone, I’m stuck while following a HuggingFace tutorial on training a text emotion recognition model. https://www.youtube.com/watch?v=u–UVvH-LIQ Almost there, but when I tried running trainer.train(), it threw an error: You're using a BertTokenizerFast tokenizer.
🌐
Databricks
kb.databricks.com › python › function-object-no-attribute
AttributeError: 'function' object has no attribute
May 19, 2022 - Problem You are selecting columns from a DataFrame and you get an error message. ERROR: AttributeError: 'function' object has no attribute '_get_object_id'
🌐
GitHub
github.com › databricks › koalas › issues › 2161
AttributeError: 'numpy.int64' object has no attribute '_get_object_id' · Issue #2161 · databricks/koalas
May 19, 2021 - a = ks.DataFrame({'source': [1,2,3,4,5]}) a.source.isin([np.int64(1), np.int64(2)]) AttributeError: 'numpy.int64' object has no attribute '_get_object_id' But this is ok a = ks.DataFrame({'source': [1,2,3,4,5]}) a.source.isin([1, 2]) Ful...
Published   May 19, 2021
Author   lepmik
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-fix-attributeerror-object-has-no-attribute
How to fix AttributeError: object has no attribute - GeeksforGeeks
August 21, 2024 - We have included the "hasattr()" function inside the if-else to add logic to our code snippet. This will avoid the AttributeError: object has no attribute error.
Find elsewhere
🌐
Apache JIRA
issues.apache.org › jira › browse › SPARK-2003
[SPARK-2003] SparkContext(SparkConf) doesn't work in pyspark - ASF Jira
July 2, 2014 - Using SparkConf with SparkContext as described in the Programming Guide does NOT work in Python: conf = SparkConf.setAppName("blah") sc = SparkContext(conf) When I tried I got AttributeError: 'SparkConf' object has no attribute '_get_object_id'
🌐
Reddit
reddit.com › r/learnpython › attributeerror: 'function' object has no attribute 'count'
r/learnpython on Reddit: AttributeError: 'function' object has no attribute 'count'
May 8, 2023 -

I am working on a Raspberry Pi Pico, programmed in Micropython. I have soldered a temperature sensor to it, and can read the values very well. The results are here: thingspeak.com...533 :-)

However, I'd like to use the average, min and max temperature values during a certain period of time (10 minutes in my current program).

Being the non-programmer, I used ChatGPT to write me a function that would give me the average values whenever I call the function. When I call avgtemp(sensor) it would add the value and return the current average, min & max values. When called avgtemp(sensor, True) it should reset the values for the next period.

ChatGPT gave me:

def avgtemp(new_value, reset=False):
    if not hasattr(avgtemp, 'count'):
        avgtemp.count = 0
        avgtemp.total = 0
        avgtemp.average = 0
        avgtemp.min = float('inf')
        avgtemp.max = float('-inf')

    if reset:
        avgtemp.count = 0
        avgtemp.total = 0
        avgtemp.average = 0
        avgtemp.min = float('inf')
        avgtemp.max = float('-inf')

    avgtemp.count += 1
    avgtemp.total += new_value
    avgtemp.average = avgtemp.total / avgtemp.count
    avgtemp.min = min(avgtemp.min, new_value)
    avgtemp.max = max(avgtemp.max, new_value)

    return avgtemp.average, avgtemp.min, avgtemp.max, avgtemp.count

But this gives me always an error: AttributeError: 'function' object has no attribute 'count'

The first if-block should take care of that: if the attribute is not initiated yet, it should create it. But this does not work... I tried to initialize the values in the beginning of the main program (where I set several other values), but could not get it to work yet...

Can someone with a better knowledge of (Micro)Python give me a pointer where I am going wrong?

Thanks in advance!

Top answer
1 of 4
6
You've named both your function and what I assume is some instance of a user-defined class the same name: avgtemp. You also don't pass that instance in.
2 of 4
2
It's a bit wonky, I suppose, but I don't immediately see any reason why this would fail with that error. So I'm guessing this must be related to how MicroPython differs from regular Python. For what it's worth, you can at least get rid of the duplication. def avgtemp(new_value, reset=False): if reset or not hasattr(avgtemp, 'count'): avgtemp.count = 0 avgtemp.total = 0 avgtemp.average = 0 avgtemp.min = float('inf') avgtemp.max = float('-inf') avgtemp.count += 1 avgtemp.total += new_value avgtemp.average = avgtemp.total / avgtemp.count avgtemp.min = min(avgtemp.min, new_value) avgtemp.max = max(avgtemp.max, new_value) return avgtemp.average, avgtemp.min, avgtemp.max, avgtemp.count One thing you can try is to turn this into a proper class, although that also means you need to change how you use it a little bit. class AverageTemperature: def __init__(self): self.count = 0 self.total = 0 self.min = float('inf') self.max = float('-inf') def reset(self): self.__init__() @property def average(self): return self.total / self.count def update(self, new_value, reset=False): if reset: self.reset() self.count += 1 self.total += new_value self.min = min(self.min, new_value) self.max = max(self.max, new_value) return self.average, self.min, self.max, self.count avg_temp = AverageTemperature() print(avg_temp.update(42)) print(avg_temp.update(55)) print(avg_temp.update(29))
🌐
Reddit
reddit.com › r/learnpython › what is "attributeerror: 'function' object has no attribute 'find'"
r/learnpython on Reddit: what is "AttributeError: 'function' object has no attribute 'find'"
June 18, 2022 -
morseCodeM={".-":"A",
            "-...":"B",
            "-.-.":"C",
            "-..":"D",
            ".":"E",
            "..-.":"F",
            "--.":"G",
            "....":"H",
            "..":"I",
            ".---":"J",
            "-.-":"K",
            ".-..":"L",
            "--":"M",
            "-.":"N",
            "---":"O",
            ".--.":"P",
            "--.-":"Q",
            ".-.":"R",
            "...":"S",
            "-":"T",
            "..-":"U",
            "...-":"V",
            ".--":"W",
            "-..-":"x",
            "-.--":"Y",
            "--..":"Z",
            " / ":" "}
def morseToText(inp):
  out=""
  while(inp!=" "):
    for i in morseCodeM:
      if(inp.find(i)!=-1):    <-----------------------
        out=out+morseCodeM[i]
        inp2=list(inp)
        inp2[inp.find(i):inp.find(i)+(len(i)-1)]=""
        inp="".join(inp2)
        return out

I honestly don't know whats wrong it just gives the error :"AttributeError: 'function' object has no attribute 'find'" on the line with the arrow .

edit: the code is about converting morse code to text

🌐
Saleae
discuss.saleae.com › logic 2 software
AttributeError: 'function' object has no attribute 'Manager' - Logic 2 Software - Saleae - Logic 2
January 3, 2024 - I am trying the API for automation testing. However, I have got two issues. Can anyone help me? Thanks! “from saleae import automation” → cannot import automation because automation is not declared in all 2.“with automation.Manager.launch(application_path) as manager” → in with saleae.automation.Manager.launch(application_path) as manager: AttributeError: ‘function’ object has no attribute ‘Manager’
🌐
Django Forum
forum.djangoproject.com › using django › forms & apis
Don't know how to fix AttributeError: 'function' object has no attribute 'pk' when trying to create new users from registration form - Forms & APIs - Django Forum
September 2, 2023 - Hi, I’m still very new to Python and Django. I am trying to create a working registration page and i get this error when submitting the form. I can’t find this error when looking on stack overflow or the forum and don’t know how to fix this issue. I copied the views and models code here.
🌐
Reddit
reddit.com › r/learnpython › object has no attribute error, but it actually does..
r/learnpython on Reddit: Object has no attribute error, but it actually does..
September 17, 2022 -

hello, i am working on a game using pygame and i am going for an OOP approach, the files are pretty big, i will post only a portion of the code; also i am using pycharm so i know for a fact my identation, typing are alright.. plus i have been coding in python for a while now but i just can't grasp onto this issue :(, so far in the game i am just in the main menu phase and whenever i try to run my code i get an error that my game object (which has a reference to another class including the main menu game loop) has no attribute ''screenWidth'' but it actually does have a variable for my screen.. i just use it in the main menu to set another midWidth variable half of that variable as value
here is the code:

main.py

from game import Game

myGame = Game()

while myGame.running:
    myGame.currentMenu.drawMainMenu()
    myGame.gameLoop()

game.py

import pygame
from menu import MainMenu


class Game:
    def __init__(self):
        pygame.init()

        self.running, self.playing = True, False
        self.upKey, self.downKey, self.selectKey, self.backKey = False, False, False, False

        self.currentMenu = MainMenu(self)

        self.screenWidth = 1280
        self.screenHeight = 720
        self.gameWindow = pygame.display.set_mode((self.screenWidth, self.screenHeight))
        pygame.display.set_caption("Game Prototype")

        self.backgroundImage = pygame.image.load('Assets/Images/bg_greek.jpg')
        self.backgroundImage = pygame.transform.scale(self.backgroundImage, (1920, 1080))

    def gameLoop(self):
        while self.playing:
            self.checkEvents()

            if self.selectKey:
                self.playing = False

            self.gameWindow.blit(self.backgroundImage, (-600, -300))

            pygame.display.flip()
            self.resetKeys()

menu.py

import pygame


class Menu:
    def __init__(self, game):
        self.gameClass = game
        self.midWidth = self.gameClass.screenWidth / 2
        self.midHeight = self.gameClass.screenHeight / 2
        self.showMenu = True
        self.selectionX, self.selectionY = 0, 0

    def drawSelection(self):
        selectSurface = pygame.Surface((260, 100), pygame.SRCALPHA)
        selectSurface.fill((50, 50, 50, 175))
        selectRect = selectSurface.get_rect()
        selectRect.center = (self.selectionX, self.selectionY)
        self.gameClass.gameWindow.blit(selectSurface, selectRect)


class MainMenu(Menu):
    def __init__(self, game):
        Menu.__init__(self, game)
        self.hoveredState = "Start"
        self.startX, self.startY = self.midWidth, self.midHeight
        self.optionsX, self.optionsY = self.midWidth, self.midHeight + 100
        self.creditsX, self.creditsY = self.midWidth, self.midHeight + 200
        self.quitX, self.quitY = self.midWidth, self.midHeight + 300
        self.selectionX, self.selectionY = self.startX, self.startY

    def drawMainMenu(self):
        self.showMenu = True
        while self.showMenu:
            self.gameClass.checkEvents()
            self.checkInput()

            self.gameClass.gameWindow.blit(self.gameClass.backgroundImage, (-600, -300))
            self.drawSelection()
            self.gameClass.drawText("Play", 72, self.startX, self.startY)
            self.gameClass.drawText("Options", 72, self.optionsX, self.optionsY)
            self.gameClass.drawText("Credits", 72, self.creditsX, self.creditsY)
            self.gameClass.drawText("Quit", 72, self.quitX, self.quitY)

            pygame.display.flip()
            self.gameClass.resetKeys()

it is not complete though

🌐
GitHub
github.com › python-poetry › poetry › issues › 2038
[AttributeError] "Call" object has no attribute "id" · Issue #2038 · python-poetry/poetry
January 5, 2021 - [x ] I am on the latest Poetry version. I have searched the issues of this repo and believe that this is not a duplicate. [x ] If an exception occurs when executing a command, I executed it again i...
Author   prakashjayy
🌐
freeCodeCamp
forum.freecodecamp.org › python
function has no attribute - Python - The freeCodeCamp Forum
March 29, 2021 - I was watching the tutorial about developing a discord bot with python. At the 27th minute I started to get an error. I searched a lot but I couldn’t find a solution. Please help me to understand the situation here. My Code is: import discord import os import json import requests client = ...