Interesting Python Packages that Deserve Our Attention

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

Convert Temperatures from Fahrenheit to Celsius

Let's use the pint package to convert a table from Fahrenheit to Celsius.

In [ ]:
# Click the Green Plane to transform this into a CrossCompute Tool
temperature_in_fahrenheit_table_path = 'temperature-in-fahrenheit.csv'
target_folder = '/tmp'
In [ ]:
import subprocess'pip install pint'.split())
In [ ]:
from pandas import read_csv
t = read_csv(temperature_in_fahrenheit_table_path)
t['Temperature in Fahrenheit'].values
In [ ]:
from pint import UnitRegistry
u = UnitRegistry()
x = (t['Temperature in Fahrenheit'].values * u.delta_degF).to(u.delta_degC)
In [ ]:
t['Temperature in Celsius'] = x.magnitude
In [ ]:
from os.path import join
target_path = join(target_folder, 'temperatures.csv')
t.to_csv(target_path, index=False)
In [ ]:
print('temperature_in_celsius_table_path = %s' % target_path)

Thanks to Hernan E. Grecco for creating pint.