While a large number of operations can be performed through the wizards, for more sophisticated tasks it may be necessary to alter the code of the nodes. For this purpose Pyplan includes a complete code editor accessible with the Code+Result or Code+Preview views.
By selecting the “Calculate Wins and Double Faults %” node as shown in the figure, and then clicking on the Code+Result view shows an example of coding:
In the code definition (Code Window) you can see how two new columns “win” and “dblfaults” are created from the original Dataframe according to the following instructions:
# Assign dataframe to the variable '_df'.
_df = data
# Create new column that checks if Federer won.
_df['win'] = _df['winner'] == 'Roger Federer'
# Create new column that calculates the % of double faults in each match.
_df['dblfaults'] = _df['player1 double faults'] / _df['player1 total points total']
result = _df
The user can experiment with altering the code in the node definition and visualize the impact on the results.
When displaying the code of a node, it can be observed that when the cursor is placed over one of the variables, a preview or help view of the variable or function being inspected is displayed after waiting a few seconds.
IntelliSense is a code completion assistant that includes a number of features: Member List, Parameter Information, Quick Info and Full Word.
These features allow you to learn more about the code you use, keep track of the parameters you write, and add property and method calls with a few keystrokes.
After typing a trigger character (for example, a dot .) , a list of valid members of a type (or namespace) appears. If you continue to type characters, the list will be filtered and will only include members that begin with those characters or where the beginning of any word in the name begins with those characters.
IntelliSense also performs “camel case” match searches, so you can type the first letter of each camel case word in the member’s name to see the matches. After selecting an item, you can insert it into the code by pressing the TAB key or inserting a space. If you select an item and type a period, the item appears followed by the period, thus displaying another list of members. When you select an item, you will get quick information about the item before inserting it.
If necessary, you can use the Pyplan bot for assistance when writing code. Make a specific inquiry to the Pyplan bot and you will receive a response ready to be embedded in a node.
It is also possible to make queries by passing the structure of a node (not its data) as context. In the following case, the bot is asked to create a node that takes as a basis the node "add_tournament_s_continent" (selected by pressing ALT + click while writing the question) and adds the number of times that win is true, according to the country.