Skip to content

Commit

Permalink
change: typings added, first test added
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobgabriel committed May 4, 2024
1 parent e596544 commit 537acb7
Show file tree
Hide file tree
Showing 22 changed files with 3,319 additions and 198 deletions.
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [2024] [Jakob Gabriel]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
69 changes: 68 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,69 @@
# timeseries-shaper pypi
# timeseries-shaper

Timeseries-Shaper is a Python library for efficiently filtering and preprocessing time series data using pandas. It provides a set of tools to handle various data transformations, making data preparation tasks easier and more intuitive.

## Features

- **Filter Missing Values**: Quickly filter out or fill missing values in your time series data.
- **Boolean Filters**: Apply boolean logic to filter data based on specific conditions.
- **Integer and Double Filters**: Perform numeric operations and filters specific to integer and double data types.
- **String Filters**: Manipulate and filter data based on string operations.

## Installation

Install timeseries-shaper using pip:

```bash
pip install timeseries-shaper
```

## Useage

Here is a quick example to get you started:

```python
import pandas as pd
from timeseries_shaper.filters import IntegerFilter, StringFilter

# Sample DataFrame
data = {
'value_integer': [1, 2, None, 4, 5],
'value_string': ['apple', 'banana', None, 'cherry', 'date']
}
df = pd.DataFrame(data)

# Initialize the filter object
integer_filter = IntegerFilter(df)
string_filter = StringFilter(df)

# Apply filters
filtered_integers = integer_filter.filter_value_integer_not_match(2)
filtered_strings = string_filter.filter_value_string_not_match('banana')

print(filtered_integers)
print(filtered_strings)
```

## Documentation

For full documentation, visit GitHub Pages or check out the docstrings in the code.

## Contributing

Contributions are welcome! For major changes, please open an issue first to discuss what you would like to change.

Please ensure to update tests as appropriate.

## License

Distributed under the MIT License. See LICENSE for more information.


## Development

- Generate new pdocs: `.\generate_docs.sh`
- Install package locally: `pip install -e .`
- Run tests locally with pytest: `pytest /tests`

- Build package for upload: `python setup.py sdist bdist_wheel`
- Upload build package to pypi: `twine upload dist/* --verbose --skip-existing`
2 changes: 1 addition & 1 deletion docs/search.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions docs/timeseries_shaper/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ <h1 class="modulename">
<div class="pdoc-code codehilite"><pre><span></span><span id="L-1"><a href="#L-1"><span class="linenos"> 1</span></a><span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
</span><span id="L-2"><a href="#L-2"><span class="linenos"> 2</span></a>
</span><span id="L-3"><a href="#L-3"><span class="linenos"> 3</span></a><span class="k">class</span> <span class="nc">Base</span><span class="p">:</span>
</span><span id="L-4"><a href="#L-4"><span class="linenos"> 4</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataframe</span><span class="p">):</span>
</span><span id="L-4"><a href="#L-4"><span class="linenos"> 4</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataframe</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">,</span> <span class="n">column_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;systime&#39;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
</span><span id="L-5"><a href="#L-5"><span class="linenos"> 5</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
</span><span id="L-6"><a href="#L-6"><span class="linenos"> 6</span></a><span class="sd"> Initializes the Base with a DataFrame.</span>
</span><span id="L-7"><a href="#L-7"><span class="linenos"> 7</span></a><span class="sd"> Args:</span>
</span><span id="L-8"><a href="#L-8"><span class="linenos"> 8</span></a><span class="sd"> - dataframe (pd.DataFrame): The DataFrame to be processed.</span>
</span><span id="L-9"><a href="#L-9"><span class="linenos"> 9</span></a><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="L-10"><a href="#L-10"><span class="linenos">10</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dataframe</span> <span class="o">=</span> <span class="n">dataframe</span><span class="o">.</span><span class="n">sort_values</span><span class="p">(</span><span class="n">by</span><span class="o">=</span><span class="s1">&#39;systime&#39;</span><span class="p">)</span>
</span><span id="L-10"><a href="#L-10"><span class="linenos">10</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dataframe</span> <span class="o">=</span> <span class="n">dataframe</span><span class="o">.</span><span class="n">sort_values</span><span class="p">(</span><span class="n">by</span><span class="o">=</span><span class="n">column_name</span><span class="p">)</span>
</span></pre></div>


Expand All @@ -89,13 +89,13 @@ <h1 class="modulename">
</div>
<a class="headerlink" href="#Base"></a>
<div class="pdoc-code codehilite"><pre><span></span><span id="Base-4"><a href="#Base-4"><span class="linenos"> 4</span></a><span class="k">class</span> <span class="nc">Base</span><span class="p">:</span>
</span><span id="Base-5"><a href="#Base-5"><span class="linenos"> 5</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataframe</span><span class="p">):</span>
</span><span id="Base-5"><a href="#Base-5"><span class="linenos"> 5</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataframe</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">,</span> <span class="n">column_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;systime&#39;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
</span><span id="Base-6"><a href="#Base-6"><span class="linenos"> 6</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
</span><span id="Base-7"><a href="#Base-7"><span class="linenos"> 7</span></a><span class="sd"> Initializes the Base with a DataFrame.</span>
</span><span id="Base-8"><a href="#Base-8"><span class="linenos"> 8</span></a><span class="sd"> Args:</span>
</span><span id="Base-9"><a href="#Base-9"><span class="linenos"> 9</span></a><span class="sd"> - dataframe (pd.DataFrame): The DataFrame to be processed.</span>
</span><span id="Base-10"><a href="#Base-10"><span class="linenos">10</span></a><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="Base-11"><a href="#Base-11"><span class="linenos">11</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dataframe</span> <span class="o">=</span> <span class="n">dataframe</span><span class="o">.</span><span class="n">sort_values</span><span class="p">(</span><span class="n">by</span><span class="o">=</span><span class="s1">&#39;systime&#39;</span><span class="p">)</span>
</span><span id="Base-11"><a href="#Base-11"><span class="linenos">11</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dataframe</span> <span class="o">=</span> <span class="n">dataframe</span><span class="o">.</span><span class="n">sort_values</span><span class="p">(</span><span class="n">by</span><span class="o">=</span><span class="n">column_name</span><span class="p">)</span>
</span></pre></div>


Expand All @@ -105,19 +105,19 @@ <h1 class="modulename">
<input id="Base.__init__-view-source" class="view-source-toggle-state" type="checkbox" aria-hidden="true" tabindex="-1">
<div class="attr function">

<span class="name">Base</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">dataframe</span></span>)</span>
<span class="name">Base</span><span class="signature pdoc-code condensed">(<span class="param"><span class="n">dataframe</span><span class="p">:</span> <span class="n">pandas</span><span class="o">.</span><span class="n">core</span><span class="o">.</span><span class="n">frame</span><span class="o">.</span><span class="n">DataFrame</span>, </span><span class="param"><span class="n">column_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;systime&#39;</span></span>)</span>

<label class="view-source-button" for="Base.__init__-view-source"><span>View Source</span></label>

</div>
<a class="headerlink" href="#Base.__init__"></a>
<div class="pdoc-code codehilite"><pre><span></span><span id="Base.__init__-5"><a href="#Base.__init__-5"><span class="linenos"> 5</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataframe</span><span class="p">):</span>
<div class="pdoc-code codehilite"><pre><span></span><span id="Base.__init__-5"><a href="#Base.__init__-5"><span class="linenos"> 5</span></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dataframe</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">,</span> <span class="n">column_name</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">&#39;systime&#39;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
</span><span id="Base.__init__-6"><a href="#Base.__init__-6"><span class="linenos"> 6</span></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
</span><span id="Base.__init__-7"><a href="#Base.__init__-7"><span class="linenos"> 7</span></a><span class="sd"> Initializes the Base with a DataFrame.</span>
</span><span id="Base.__init__-8"><a href="#Base.__init__-8"><span class="linenos"> 8</span></a><span class="sd"> Args:</span>
</span><span id="Base.__init__-9"><a href="#Base.__init__-9"><span class="linenos"> 9</span></a><span class="sd"> - dataframe (pd.DataFrame): The DataFrame to be processed.</span>
</span><span id="Base.__init__-10"><a href="#Base.__init__-10"><span class="linenos">10</span></a><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="Base.__init__-11"><a href="#Base.__init__-11"><span class="linenos">11</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dataframe</span> <span class="o">=</span> <span class="n">dataframe</span><span class="o">.</span><span class="n">sort_values</span><span class="p">(</span><span class="n">by</span><span class="o">=</span><span class="s1">&#39;systime&#39;</span><span class="p">)</span>
</span><span id="Base.__init__-11"><a href="#Base.__init__-11"><span class="linenos">11</span></a> <span class="bp">self</span><span class="o">.</span><span class="n">dataframe</span> <span class="o">=</span> <span class="n">dataframe</span><span class="o">.</span><span class="n">sort_values</span><span class="p">(</span><span class="n">by</span><span class="o">=</span><span class="n">column_name</span><span class="p">)</span>
</span></pre></div>


Expand Down
6 changes: 3 additions & 3 deletions docs/timeseries_shaper/filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ <h2>Submodules</h2>
<ul>
<li><a href="filter/boolean_filter.html">boolean_filter</a></li>
<li><a href="filter/custom_filter.html">custom_filter</a></li>
<li><a href="filter/datetime_filters.html">datetime_filters</a></li>
<li><a href="filter/numeric_filters.html">numeric_filters</a></li>
<li><a href="filter/string_filters.html">string_filters</a></li>
<li><a href="filter/datetime_filter.html">datetime_filter</a></li>
<li><a href="filter/numeric_filter.html">numeric_filter</a></li>
<li><a href="filter/string_filter.html">string_filter</a></li>
</ul>


Expand Down
Loading

0 comments on commit 537acb7

Please sign in to comment.