1

I have dataframe objects that I would like to to pass into a function.

x = pd.Dataframe()

def function(z):
    "code"
    return result

result = function(x)

I'm new to python, can someone please steer me in the right direction.

2
  • 3
    Your question makes zero sense, there's no explanation of where you're stuck or what you expect your function to do Commented Apr 26, 2016 at 18:14
  • 1
    Thanks for your help EdChum, really appreciated. I have a dataframe object = x that I want to pass to a function <def function(z)> so I can manipulate and format my dataframe. Again I'm new to python and just wanted some feedback on how I would do this. Commented Apr 26, 2016 at 18:45

1 Answer 1

8

Below I am showing a simple function that would have the input parameter as a DataFrame object, and it would check if one of the columns has the String "Some", if so, it returns the Boolean results.

Check if this helps.

x = pd.DataFrame([[1,'Some Text'],[2,'New Text']],columns=('SINO','String_Column'))

def function(z):
    l_local_df = z['String_Column'].str.contains('Some')
    return l_local_df

result = function(x)
print result
Sign up to request clarification or add additional context in comments.

1 Comment

thank you. Wasn't sure if it was possible since I was getting an error.

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.