Jupyter Notebook Tips




Pay Notebook Creator: Roy Hyunjin Han0
Set Container: Numerical CPU with TINY Memory for 10 Minutes 0
Total0

Type Your Tool Title Here

Describe your tool in Markdown syntax. Be sure to give thanks to the people who helped you!

  • Specifying a tool template is optional.
  • Specifying input arguments in the tool template is optional.
  • Omit the path suffix when configuring input arguments.

{ a : Variable Named A ? Write tooltips to help your users understand each input argument }

{ a_select : Fruit Selection ? Choose your favorite fruits }

{ a_text : Some Text }

{ a_table ? Thanks! }

In [17]:
"""
Specify your input arguments in the first code cell

- Add a comment with the word CrossCompute in the first code cell to indicate that your notebook defines a tool
- Do not put import statements in the first code cell
- To accept text, use x_text_path
- To render a table, use x_table_path
- [See other tool notebooks for more data types](https://crosscompute.com/tools)
- Be sure that any files you specify are in the same folder as this notebook
"""
# CrossCompute
a = 1
a_select = """
    Orange
    Tomato

    Avocado
    Banana
    Orange
    Pear
    Tomato
"""
a_text_path = 'example.csv'
a_table_path = 'example.csv'
a_geotable_path = 'example.csv'
# Note that target_folder is a special argument and must be spelled exactly
target_folder = '/tmp'
In [ ]:
"""
Print output properties in any code cell to render them on the result page

- To render a value, use y = 1
- To render a text file saved in target_folder, use y_text_path = target_folder + '/y.txt'
- To render a table file saved in target_folder, use y_table_path = target_folder + '/y.csv'
- [See other tool notebooks for more data types](https://crosscompute.com/tools)

Press the Red Button to deploy your tool on the CrossCompute website
"""
print('variable_names_must_not_have_spaces = %s' % (a + 1))
print('selected_fruits = %s' % ' '.join(a_select.splitlines()))
In [ ]:
# Type your algorithm code here
In [ ]:
# Press CTRL-ENTER to run a code cell
# Press SHIFT-ENTER to run a code cell and move to the next cell
# Press ALT-ENTER to run a code cell and insert a new code cell

import pandas as pd
# Load table
a_table = pd.read_csv(a_table_path)
a_table[:2]
In [ ]:
# Press CTRL-SHIFT-HYPHEN to split a cell
# Press ESC-h to see more keyboard shortcuts

from geotable import GeoTable
# Load geotable
a_geotable = GeoTable.load(a_geotable_path)
a_geotable.draw()
In [ ]:
# Save your output files in target_folder
%matplotlib inline
target_path = target_folder + '/plot.png'
ax = a_table.plot(kind='bar')
ax.set_xticklabels(a_table['Description'], rotation=45);
figure = ax.get_figure()
figure.savefig(target_path)

# Render the file as an image
print('abcdef_image_path = %s' % target_path)
In [ ]:
# Save your output files in target_folder
target_path = target_folder + '/map.csv'
a_table.to_csv(target_path, index=False)

# Render the file as a text
print('abcdef_text_path = %s' % target_path)
# Render the file as a table
print('abcdef_table_path = %s' % target_path)
# Render the file as a geotable
print('abcdef_geotable_path = %s' % target_path)
In [ ]:
# Specify colors
table_with_fill_color = a_table.copy()
table_with_fill_color['FillColor'] = [
    'r',
    'b',
    '#ff565f',
    'purple',
]
target_path = target_folder + '/map-with-fill-color.csv'
table_with_fill_color.to_csv(target_path, index=False)
print('abcdef_geotable_path = %s' % target_path)
In [ ]:
# Assign shades of red based on value
table_with_fill_reds = a_table.copy()
table_with_fill_reds['FillReds'] = a_table['Level']
target_path = target_folder + '/map-with-fill-reds.csv'
table_with_fill_reds.to_csv(target_path, index=False)
print('abcdef_geotable_path = %s' % target_path)
In [ ]:
print('abcdef_satellite_geotable_path = %s' % target_path)

Type Your Result Title Here

You can use this space to specify links to more information.

  • Specifying a result template is optional.
  • Specifying output properties in the result template is optional.
  • Omit the path suffix when configuring output properties.

{ variable_names_must_not_have_spaces : X ? Hmm }

{ selected_fruits : Selected Fruits }

{ abcdef_image : An Image }

{ abcdef_text : Some Text }

{ abcdef_table : A Table }

{ abcdef_geotable : A Map }

Learn how to render different data types.

Click here to see a list of supported data types.