units-of-measurement

Automatic reduction and cancellation of units with SymPy

Automatic reduction and cancellation of units with SymPy Question: I am having issues with getting units to cleanly simplify. The program I am writing is involved with the calculation of spring properties, requiring 10/11 user controlled variables and about a dozen equations, all of which deal with mixed sets of units. The one missing variable …

Total answers: 1

How are currency units used with Python Pint units?

How are currency units used with Python Pint units? Question: I would like to do something like this: import pint ureg = pint.UnitRegistry() kg = ureg.kg USD = ureg.USD # not the way to do this weight = 2.3 * kg price = 1.49 * USD / kg cost = weight * price print(f"{cost:~.2f}") >>> …

Total answers: 1

How can I manage units in pandas data?

How can I manage units in pandas data? Question: I’m trying to figure out if there is a good way to manage units in my pandas data. For example, I have a DataFrame that looks like this: length (m) width (m) thickness (cm) 0 1.2 3.4 5.6 1 7.8 9.0 1.2 2 3.4 5.6 7.8 …

Total answers: 3

Simple unit converter in Python

Simple unit converter in Python Question: I am new to programming and I am trying to make a simple unit converter in python. I want to convert units within the metric system and metric to imperial and vice-versa. I have started with this code and I found this method is slow and in-efficient, How can …

Total answers: 5

Separate number from unit in a string in Python

Separate number from unit in a string in Python Question: I have strings containing numbers with their units, e.g. 2GB, 17ft, etc. I would like to separate the number from the unit and create 2 different strings. Sometimes, there is a whitespace between them (e.g. 2 GB) and it’s easy to do it using split(‘ …

Total answers: 14

Unit Conversion in Python

Unit Conversion in Python Question: I’m working on a project that lets users track different data types over time. Part of the base idea is that a user should be able to enter data using any units that they need to. I’ve been looking at both units: http://pypi.python.org/pypi/units/ and quantities: http://pypi.python.org/pypi/quantities/ However I’m not sure …

Total answers: 13