Python Forum
function parameter function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
function parameter function
#1
Hi i am new in python. i want to a function with a paremeter which is also function. My code is over there.
import pandas as pd
veri=pd.read_csv("Data.csv")
veri

def veri_cek(alan,fonksiyon,deger):
    return veri.loc[veri[alan].fonksiyon(deger)]

print(veri_cek2('Age',"gt",40))
this is the error message..
Error:
AttributeError Traceback (most recent call last) <ipython-input-41-78b5dcc3807d> in <module> ----> 1 print(veri_cek2('Age',"gt",40)) <ipython-input-38-aa42b137d68d> in veri_cek2(alan, fonksiyon, deger) 1 def veri_cek2(alan,fonksiyon,deger): ----> 2 return veri.loc[veri[alan].fonksiyon(deger)] ~\Anaconda3\envs\IstatistikUygulamaliVeriMadenci\lib\site-packages\pandas\core\generic.py in __getattr__(self, name) 5065 if self._info_axis._can_hold_identifiers_and_holds_name(name): 5066 return self[name] -> 5067 return object.__getattribute__(self, name) 5068 5069 def __setattr__(self, name, value): AttributeError: 'Series' object has no attribute 'fonksiyon'
Please anybody can help me?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question how to write a function that accepts a 1D array as a parameter in Python SuperNinja3I3 1 1,620 Jul-02-2022, 01:55 PM
Last Post: Larz60+
  Function for the Normal Loss Function L(z) Smelly 1 4,982 Feb-01-2019, 11:49 AM
Last Post: scidam
  Question about calling a function that calls a function Afterdarkreader 9 5,015 Dec-09-2017, 10:07 PM
Last Post: ezdev

Forum Jump:

User Panel Messages

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