Some simple tools for working with parsed Sensospot data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.7 KiB

Sensospot Tools
===============
Some small tools for working with parsed Sensospot data.
2 years ago
## Selecting and spliting a pandas data frame
2 years ago
### 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
2 years ago
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
2 years ago
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.