-
Notifications
You must be signed in to change notification settings - Fork 111
Features/allow data heigts of type string #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
windpowerlib/modelchain.py
Outdated
| # Convert data heights to integer. In some case they are strings. | ||
| weather_df.columns = pd.MultiIndex.from_arrays([ | ||
| weather_df.columns.get_level_values(0), | ||
| weather_df.columns.get_level_values(1).astype(int)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why int and not float type? In the provided example the values are integers but that shouldn't be a rule, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion the inaccuracy of the model is higher than the decimal digit. Therefore I would always prefer integer.
But at them moment floats are allowed and it might be easier to allow floats than to forbid them and to explain why.
windpowerlib/modelchain.py
Outdated
| weather_df.columns = pd.MultiIndex.from_arrays([ | ||
| weather_df.columns.get_level_values(0), | ||
| weather_df.columns.get_level_values(1).astype(int)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe putting in a try statement and re-raising the error? In case someone passes in 80 m that cannot be converted to a number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me the error message is quite clear. It also indicates the exact value that causes the problem. For us it would be more difficult to indicate the problematic value. We could add something like "The heights should be convertible to numeric." but it in my opinion the original message is better. We could also check the array and show all problematic values but I think it is not worth it.
Fix: #86
The
read_csv()function of pandas read column names as strings. In a weather file the second level of the columns are the data heights. These heights should be of type integer.With this PR these values are converted into integer values.