question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow undefined units?

See original GitHub issue

Currently, pyam raises an error when initializing from a pandas.DataFrame with nan or when reading from xlsx/csv with empty cells in any index/coordinate dimension. This makes sense for model, scenario, variable and region, but there could be timeseries without a natural unit (e.g., population or number power plants if not given in an order of magnitude, shares, probabilities if given on the range [0, 1]).

The reason why this was introduced in the first place is that pandas has issues when filtering and other operations when nan are present.

One solution could be to allow variables without units by replacing nan with '' (an empty string). That way, filtering and other operations should behave as expected, and writing to csv/xlsx should again generate empty cells (same as the original when reading from a file).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
znichollscommented, Nov 2, 2020

For examples of unitless variables

I’m not sure I agree with any of these, I would say all of these are either ‘dimensionless’ or some derived unit based on mole. The point here being that I can’t see any case in which you’d want to encourage not having a unit.

Irrespective of that, reading empty of missing cells as an empty string for units sounds like a good solution to me.

1reaction
znichollscommented, Nov 1, 2020

timeseries without a natural unit

Of the examples given, the typical pint unit is ‘dimensionless’. Specifying that explicitly can be helpful, particularly if you ever want to add unit aware operations (e.g. https://github.com/openscm/scmdata/blob/master/notebooks/ops.ipynb https://scmdata.readthedocs.io/en/latest/scmdata.ops.html) in future.

I’m trying to think now, and I can’t think of any timeseries which would actually have no unit but maybe my imagination is too limited.

You could simply assume dimensionless if nothing else is provided?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Allow undefined function calls in TypeScript to test for ...
Meaning I can't compile my TypeScript unit-test. The best workaround I have so far is to define these types of unit-tests as JavaScript...
Read more >
"Allow Undefined Values" interface refinement - NI Community
When we use the "Allow Undefined Values" functionality of a ring control for example, this is not graphically done by allowing entry within....
Read more >
Handle undefined values - Palantir
Below are two useful patterns for handling undefined values which may be returned from accessing properties or links. By checking that both the...
Read more >
Handling null and undefined in JavaScript | by Eric Elliott
In some statically typed languages, you can say that null and undefined are illegal values, and let your programming language throw a TypeError ......
Read more >
c++ - Philosophy behind Undefined Behavior
The existence of undefined behavior allows a program to use non-portable features ... C was invented on a machine with 9bit bytes and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found