cat-data-tools 1.2.0__tar.gz → 1.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cat_data_tools
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: A Python module to process cats data
5
5
  Home-page: https://github.com/IslasGECI/cat_data_tools
6
6
  Author: Ciencia de Datos • GECI
@@ -1,6 +1,6 @@
1
1
  """A Python module to process cats data"""
2
2
 
3
- __version__ = "1.2.0"
3
+ __version__ = "1.3.0"
4
4
  from .cli import * # noqa
5
5
  from .filter_data_between_years import * # noqa
6
6
  from .filter_data_by_month import * # noqa
@@ -10,7 +10,7 @@ from cat_data_tools.calculate_effort_and_captures import calculate_effort_and_ca
10
10
  from cat_data_tools.detect_status_change import (
11
11
  compute_trap_check_log,
12
12
  )
13
- from cat_data_tools.filter_data_between_years import filter_data_between_years
13
+ from cat_data_tools.filter_data_between_years import filter_data_between_years, filter_between_dates
14
14
  from cat_data_tools.summary_posterior_results import compute_posterior_summary
15
15
  from cat_data_tools.update_status_traps import _update_status_traps
16
16
  from cat_data_tools.transform_effort_captures import transform_effort_captures_to_dict
@@ -18,6 +18,7 @@ import cat_data_tools as cdt
18
18
  import pandas as pd
19
19
  import json
20
20
  import typer
21
+ import warnings
21
22
 
22
23
  app = typer.Typer()
23
24
 
@@ -144,18 +145,45 @@ def write_monthly_summary(
144
145
  monthly_data.to_csv(output_path, index=False, na_rep="NA")
145
146
 
146
147
 
147
- @app.command(help="Filter monthly summary between years")
148
+ @app.command(help="Filter monthly summary between years", deprecated=True)
148
149
  def filter_monthly_summary(
149
150
  monthly_data_path: str = "",
150
151
  output_path: str = "",
151
152
  initial_year: int = 2014,
152
153
  final_year: int = 2019,
153
154
  ):
155
+ warnings.warn("Use write-filtered-monthly-summary-between-years instead", DeprecationWarning)
156
+
154
157
  dataframe = pd.read_csv(monthly_data_path)
155
158
  filtered_dataframe = filter_data_between_years(dataframe, initial_year, final_year)
156
159
  filtered_dataframe.to_csv(output_path, index=False, na_rep="NA")
157
160
 
158
161
 
162
+ @app.command(help="Filter monthly summary between years")
163
+ def write_filtered_monthly_summary_between_years(
164
+ monthly_data_path: str = "",
165
+ output_path: str = "",
166
+ initial_year: int = 2014,
167
+ final_year: int = 2019,
168
+ ):
169
+ dataframe = pd.read_csv(monthly_data_path)
170
+ filtered_dataframe = filter_data_between_years(dataframe, initial_year, final_year)
171
+ filtered_dataframe.to_csv(output_path, index=False, na_rep="NA")
172
+
173
+
174
+ @app.command(help="Filter data between given dates.")
175
+ def write_filtered_data_between_dates(
176
+ data_path: str = "",
177
+ output_path: str = "",
178
+ initial_date: str = "",
179
+ final_date: str = "",
180
+ ):
181
+ df = pd.read_csv(data_path)
182
+ date_column_name = "Fecha"
183
+ filtered_data = filter_between_dates(df, initial_date, final_date, date_column_name)
184
+ filtered_data.to_csv(output_path, index=False)
185
+
186
+
159
187
  @app.command()
160
188
  def update_status_traps(data_path: str = typer.Option(), output_path: str = typer.Option()):
161
189
  traps_info_df = pd.read_csv(data_path)
@@ -1,6 +1,12 @@
1
1
  import pandas as pd
2
2
 
3
3
 
4
+ def filter_between_dates(dataframe, initial_date, final_date, date_column_name):
5
+ is_date_after_initial_date = dataframe[date_column_name] >= initial_date
6
+ is_date_before_final_date = dataframe[date_column_name] <= final_date
7
+ return dataframe.loc[is_date_after_initial_date & is_date_before_final_date]
8
+
9
+
4
10
  def filter_data_between_years(monthly_data, initial_year, final_year=2260):
5
11
  data_after_year = filter_data_after_year(monthly_data, initial_year)
6
12
  return filter_data_before_year(data_after_year, final_year)
File without changes
File without changes