|
|
|
Sensospot Tools
|
|
|
|
===============
|
|
|
|
|
|
|
|
Some small tools for working with parsed Sensospot data.
|
|
|
|
|
|
|
|
## Selecting and spliting a pandas data frame
|
|
|
|
|
|
|
|
### sensospot_tools.select(data: DataFrame, column: str, value: Any) -> DataFrame
|
|
|
|
|
|
|
|
Selects rows of a dataframe based on a value in a column
|
|
|
|
|
|
|
|
Example:
|
|
|
|
```python
|
|
|
|
|
|
|
|
from sensospot_tools import select
|
|
|
|
|
|
|
|
print(data)
|
|
|
|
category value
|
|
|
|
0 dog 1
|
|
|
|
1 cat 2
|
|
|
|
2 horse 3
|
|
|
|
3 cat 4
|
|
|
|
|
|
|
|
print(select(data, "category", "cat"))
|
|
|
|
category value
|
|
|
|
1 cat 2
|
|
|
|
3 cat 4
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### sensospot_tools.split(data: DataFrame, column: str) -> Iterator[tuple[Any, DataFrame]]
|
|
|
|
|
|
|
|
Splits a data frame on unique values in a column
|
|
|
|
|
|
|
|
Returns an iterator where each result is key-value-pair. The key is the
|
|
|
|
unique value used for the split, the value is a slice of the dataframe
|
|
|
|
selected by the unique value contained in the column.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
```python
|
|
|
|
|
|
|
|
from sensospot_tools import split
|
|
|
|
|
|
|
|
print(data)
|
|
|
|
category value
|
|
|
|
0 dog 1
|
|
|
|
1 cat 2
|
|
|
|
2 horse 3
|
|
|
|
3 cat 4
|
|
|
|
|
|
|
|
result = dict( split(data, column="category") )
|
|
|
|
|
|
|
|
print(result["dog"])
|
|
|
|
category value
|
|
|
|
0 dog 1
|
|
|
|
|
|
|
|
print(result["cat"])
|
|
|
|
category value
|
|
|
|
1 cat 2
|
|
|
|
3 cat 4
|
|
|
|
|
|
|
|
print(result["horse"])
|
|
|
|
category value
|
|
|
|
2 horse 3
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Development
|
|
|
|
|
|
|
|
To install the development version of Sensospot Tools:
|
|
|
|
|
|
|
|
git clone https://git.cpi.imtek.uni-freiburg.de/holgi/sensospot_tools.git
|
|
|
|
|
|
|
|
# create a virtual environment and install all required dev dependencies
|
|
|
|
cd sensospot_tools
|
|
|
|
make devenv
|
|
|
|
|
|
|
|
To run the tests, use `make tests` or `make coverage` for a complete report.
|