Python Forum
Argument lists - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Argument lists (/thread-5669.html)



Argument lists - sobrio1 - Oct-15-2017

Does anyone know how to get an argument list for a function besides using shift+tab?

I can't use my_dataframe.loc() properly because I have no idea what arguments I need to give it (and shift+tab gives me no information)

Thanks!


RE: Argument lists - ichabod801 - Oct-15-2017

That sounds to be IDE specific. I would use the help() function in the Python interpreter. Is this a pandas dataframe? There's documentation online for that.


RE: Argument lists - sobrio1 - Oct-15-2017

Yes, it's a pandas dataframe. I didn't find any argument lists through help.
Not really sure what IDEs and Python interpreters are. Is Jupyter Notebook an interpreter, or Anacondas, or Idle?

It's funny, I've been through the documentation you linked about 10 times now but it doesn't tell me a single thing about parameter arguments. I assumed Python would post function arguments somewhere. Is shift+tab really the only way python programmers can get an argument list?


RE: Argument lists - ichabod801 - Oct-15-2017

It's an attribute that works as an indexer. It doesn't have arguments. The link for the documentation on loc is right there on the page I linked to. So are argument lists for all of the methods of the dataframe object.


RE: Argument lists - sobrio1 - Oct-15-2017

I'm sorry, maybe I'm calling them 'arguments' and it's really something else (I'm new obviously).

I'm looking for an argument list such as my_df.loc(start = , end = , arg3 = , ....argfinal = )
I really appreciate the help, but the loc documentation definitely doesn't have it.


RE: Argument lists - ichabod801 - Oct-15-2017

That's not how you use loc. It's not callable, so it doesn't have an argument list. You use it with brackets (my_df.loc['a']) for indexing.


RE: Argument lists - sobrio1 - Oct-16-2017

Sorry - I was focused on getting the arguments, not syntax. The code below is running perfectly on the titanic dataset from Kaggle - tdf is my dataframe. However, I would like to know what options/arguments are all available with a predefined function like loc.

print(tdf.loc[5])
print(tdf.loc[5, ['Pclass', 'Name']])
print(tdf.loc[7:9])

Clearly, since all the code above works fine for me, I have something like:
loc[start= : end= , columns = [ ]] (Just guessing here, and there must be more to it)
But if I hadn't guessed this from snippets here and there, how would I know? I'm trying to find documentation on all options/arguments for a given python function, in a general way, just using loc for example.

If I use shift+tab with something like tdf.index() I immediately get the following docstring:
String form: RangeIndex(start=0, stop=891, step=1)
This is very helpful - how do I get something like this for loc?


RE: Argument lists - ichabod801 - Oct-16-2017

loc is not a function. If you want to understand how to use it, read a tutorial on pandas dataframes. It does indexing, like a list, but it's a bit more complicated. If you look at the loc documentation it has a link explaining the usage.

If you want the signature for a function, you type help(function) in the Python interpreter. There might be something useful if you type help(tdf.loc), but I don't have pandas installed at the moment, so I'm not sure.