-
Notifications
You must be signed in to change notification settings - Fork 13
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
Fixing Pandas deprecation warnings. #855
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #855 +/- ##
=======================================
Coverage 83.65% 83.66%
=======================================
Files 192 192
Lines 33601 33636 +35
=======================================
+ Hits 28110 28142 +32
- Misses 5491 5494 +3 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
@@ -877,10 +877,10 @@ def derive_from_dataframe(self, | |||
@staticmethod | |||
def __cell_kji0_from_df(df, df_row): | |||
row = df.iloc[df_row] | |||
if pd.isna(row[0]) or pd.isna(row[1]) or pd.isna(row[2]): | |||
if pd.isna(row.iloc[0]) or pd.isna(row.iloc[1]) or pd.isna(row.iloc[2]): |
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.
Let's discuss these changes as I'm hazy about the use of iloc here.
Checking for deprecation warnings. Unable to replicate the deprecation warnings mentioned by @andy-beer, currently working on resolving those sent directly:
warnings summary ====================================================================
tests/unit_tests/derived_model/test_derived_model.py::test_add_wells_from_ascii_file
tests/unit_tests/well/test_well_object_funcs.py::test_add_wells_from_ascii_file
tests/unit_tests/well/test_well_object_funcs.py::test_add_wells_from_ascii_file
/Users/andy/bifröst/resqpy_repo/resqpy/well/well_object_funcs.py:80: FutureWarning: The 'delim_whitespace' keyword in pd.read_csv is deprecated and will be removed in a future version. Use
sep='\s+'
insteaddf = pd.read_csv(trajectory_file,
tests/unit_tests/fault/test_fault.py::test_add_connection_set_and_tmults[inc_list0-tmult_dict0-expected_mult0]
tests/unit_tests/fault/test_fault.py::test_add_connection_set_and_tmults[inc_list1-tmult_dict1-expected_mult1]
tests/unit_tests/fault/test_fault.py::test_add_connection_set_and_tmults[inc_list2-tmult_dict2-expected_mult2]
tests/unit_tests/olio/test_read_nexus_fault.py::test_load_nexus_fault_mult_table[basic]
/Users/andy/bifröst/resqpy_repo/resqpy/olio/read_nexus_fault.py:117: FutureWarning: errors='ignore' is deprecated and will raise in a future version. Use to_numeric without passing
errors
and catch exceptions explicitly insteaddf[column] = pd.to_numeric(df[column], errors = 'ignore')
tests/unit_tests/fault/test_fault.py::test_add_connection_set_and_tmults[inc_list2-tmult_dict2-expected_mult2]
tests/unit_tests/olio/test_read_nexus_fault.py::test_load_nexus_fault_mult_table[basic]
/Users/andy/bifröst/resqpy_repo/resqpy/olio/read_nexus_fault.py:67: FutureWarning: errors='ignore' is deprecated and will raise in a future version. Use to_numeric without passing
errors
and catch exceptions explicitly insteaddf[column] = pd.to_numeric(df[column], errors = 'ignore')
tests/unit_tests/olio/test_relperm.py::test_col_headers
tests/unit_tests/olio/test_relperm.py::test_missing_vals
tests/unit_tests/olio/test_relperm.py::test_monotonicity
tests/unit_tests/olio/test_relperm.py::test_range
tests/unit_tests/olio/test_relperm.py::test_relperm
tests/unit_tests/olio/test_relperm.py::test_relperm_no_phase_combo[test_cols0-water-oil]
tests/unit_tests/olio/test_relperm.py::test_relperm_no_phase_combo[test_cols1-gas-oil]
tests/unit_tests/olio/test_relperm.py::test_relperm_no_phase_combo[test_cols2-gas-water]
/Users/andy/bifröst/resqpy_repo/resqpy/olio/relperm.py:94: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.
For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.
tests/unit_tests/well/test_blocked_well.py: 12 warnings
tests/unit_tests/well/test_well_object_funcs.py: 1 warning
tests/unit_tests/well/test_well_utils.py: 1 warning
/Users/andy/bifröst/resqpy_repo/resqpy/well/_blocked_well.py:880: FutureWarning: Series.getitem treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use
ser.iloc[pos]
if pd.isna(row[0]) or pd.isna(row[1]) or pd.isna(row[2]):
tests/unit_tests/well/test_blocked_well.py: 12 warnings
tests/unit_tests/well/test_well_object_funcs.py: 1 warning
tests/unit_tests/well/test_well_utils.py: 1 warning
/Users/andy/bifröst/resqpy_repo/resqpy/well/_blocked_well.py:883: FutureWarning: Series.getitem treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use
ser.iloc[pos]
cell_kji0[:] = row[2], row[1], row[0]
tests/unit_tests/well/test_deviation_survey.py::test_DeviationSurvey
/Users/andy/bifröst/resqpy_repo/resqpy/well/_deviation_survey.py:236: FutureWarning: The 'delim_whitespace' keyword in pd.read_csv is deprecated and will be removed in a future version. Use
sep='\s+'
insteaddf = pd.read_csv(deviation_survey_file,
tests/unit_tests/well/test_trajectory.py::test_load_from_ascii_file
tests/unit_tests/well/test_trajectory.py::test_load_from_ascii_file
tests/unit_tests/well/test_trajectory.py::test_arrays
/Users/andy/bifröst/resqpy_repo/resqpy/well/_trajectory.py:513: FutureWarning: The 'delim_whitespace' keyword in pd.read_csv is deprecated and will be removed in a future version. Use
sep='\s+'
insteaddf = pd.read_csv(trajectory_file,
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================ short test summary info ================================================================
SKIPPED [1] tests/unit_tests/test_resqpy.py:25: need --buildtest option to run
===================================================== 1189 passed, 1 skipped, 49 warnings in 23.72s