Skip to content

Commit

Permalink
fix: Docs, fixes because of changed memory_optimize
Browse files Browse the repository at this point in the history
Docstrings.

Several fixes because tsutils.memory_optimize is less aggressive.

Horizontal and vertical lines in `plot`

Most of butterworth filter in `filter`
  • Loading branch information
timcera committed Feb 15, 2021
1 parent 10e79ae commit f019cda
Show file tree
Hide file tree
Showing 10 changed files with 475 additions and 121 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@
"console_scripts": ["{pkg_name}={pkg_name}.{pkg_name}:main".format(**locals())]
},
test_suite="tests",
python_requires=">=3.6",
python_requires=">=3.7.1",
)
8 changes: 4 additions & 4 deletions tstoolbox/functions/accumulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ def accumulate_cli(
Parameters
----------
statistic : str
[optional, default is 'sum', transformation]
statistic : Union(str, list(str))
[optional, default is "sum", transformation]
Any of 'sum', 'max', 'min', 'prod' or list of same.
OneOrMore("sum", "max", "min", "prod")
Python example::
statistic=['sum', 'max']
statistic=["sum", "max"]
Command line example::
--statistic=sum,max
Expand Down
13 changes: 12 additions & 1 deletion tstoolbox/functions/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def aggregate_cli(
target_units=None,
print_input=False,
tablefmt="csv",
skipna=True,
):
"""Take a time series and aggregate to specified frequency.
Expand Down Expand Up @@ -74,6 +75,12 @@ def aggregate_cli(
{target_units}
{print_input}
{tablefmt}
skipna : bool
[optional, defaults to True, transformation]
If False will return a NaN for any aggregation group that has a NaN.
If True will fill all NaNs with 0 before aggregation. Ignored if
`groupby` is "all" or `groupby` is "months_across_years".
agg_interval :
DEPRECATED:
Use the 'groupby' option instead.
Expand All @@ -100,6 +107,7 @@ def aggregate_cli(
source_units=source_units,
target_units=target_units,
print_input=print_input,
skipna=skipna,
),
tablefmt=tablefmt,
)
Expand Down Expand Up @@ -144,6 +152,7 @@ def aggregate(
source_units=None,
target_units=None,
print_input=False,
skipna=True,
):
"""Take a time series and aggregate to specified frequency."""
aggd = {"hourly": "H", "daily": "D", "monthly": "M", "yearly": "A", "all": "all"}
Expand Down Expand Up @@ -235,7 +244,9 @@ def aggregate(
tmptsd.index = list(range(1, 13))
else:
tmptsd = eval(
"""tsd.resample('{0}{1}').{2}()""".format(ninterval, groupby, method)
"""tsd.resample('{0}{1}').agg(pd.Series.{2}, skipna={3})""".format(
ninterval, groupby, method, skipna
)
)
tmptsd.columns = [tsutils.renamer(i, method) for i in tmptsd.columns]
newts = newts.join(tmptsd, how="outer")
Expand Down
2 changes: 1 addition & 1 deletion tstoolbox/functions/date_offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def date_offset(
clean=clean,
)

return tsd.tshift(intervals, offset)
return tsd.shift(intervals, offset)


date_offset.__doc__ = date_offset_cli.__doc__
12 changes: 6 additions & 6 deletions tstoolbox/functions/equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,21 +254,21 @@ def returnval(t, x, testeval, nequation):
tsearch, nsearch, testeval, nequation = _parse_equation(eqn)
if tsearch and nsearch:
y = pd.DataFrame(
pd.Series(index=x.index, dtype="float64"),
pd.Series(index=x.index, dtype="Float64"),
columns=["_"],
dtype="float64",
dtype="Float64",
)
for t in range(len(x)):
y.iloc[t, 0] = returnval(t, x, testeval, nequation)
elif tsearch:
y = x.copy()
y = x.astype("Float64")
for t in range(len(x)):
y.iloc[t, :] = returnval(t, x, testeval, nequation)
elif nsearch:
y = pd.DataFrame(
pd.Series(index=x.index, dtype="float64"),
pd.Series(index=x.index, dtype="Float64"),
columns=["_"],
dtype="float64",
dtype="Float64",
)
try:
y.iloc[:, 0] = eval(nequation)
Expand All @@ -286,7 +286,7 @@ def returnval(t, x, testeval, nequation):

else:
y = eval(eqn)
y.columns = [tsutils.renamer(i, "equation.{0}".format(cnt)) for i in y.columns]
y.columns = [tsutils.renamer(i, "equation{0}_".format(cnt)) for i in y.columns]
newy = newy.join(y, how="outer")

newy = tsutils.memory_optimize(newy)
Expand Down
Loading

0 comments on commit f019cda

Please sign in to comment.