Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Argument lists
#1
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!
Quote
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#3
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?
Quote
#4
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#5
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.
Quote
#6
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#7
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?
Quote
#8
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.
sobrio1 likes this post
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)