semvec/pypi-packages huggingface dataset:
prompt-horizon 0.1.4
Library to anonymize JSON objects by creating placeholders for keys and values, while generating a reversible mapping to restore afterwards

# Prompt-Horizon

**Prompt-Horizon** is a Python library that enables developers to anonymize JSON objects by creating placeholders for keys and values, while generating a reversible mapping to restore the original JSON data. The purpose of this library is to facilitate data sharing while preserving privacy and allowing for the de-anonymization of the data when required.

*Note: I had the idea for this library when I was trying to find a way to obfuscate data objects such as JSON to include them as contextual information in prompts (hence the name).*

**Prompt-Horizon is not designed to specifically identify and anonymize PII (personally identifiable information) or other sensitive data within the JSON objects.**

<br>

## Installation

```bash
pip install prompt-horizon
```

## Usage

### Anonymize JSON

<br>

```python
from prompt_horizon import anonymize

input_json = {
    "name": "John",
    "age": 30,
    "city": "New York",
    "favorites": ["pizza", "basketball"]
}

#This line will return the anonymized JSON object and the mapping object.
anonymized_json, map_object = anonymize(input_json)
```

Original JSON:

```json
{
    "name": "John",
    "age": 30,
    "city": "New York",
    "favorites": ["pizza", "basketball"]
}
```

Anonymized JSON:

```json
{
    "a1": "a2",
    "a3": "a4",
    "a5": "a6",
    "a7": ["a8", "a9"]
}
```
<br>

#### input and output file handling is supported

```python
from prompt_horizon import anonymize

#This line will read the JSON data from "input.json", anonymize it, and save the anonymized JSON to "anonymized.json".
anonymized_json, map_object = anonymize("input.json", output_file_path="anonymized.json")
```

<br>

#### anonymize only the values

```python
from prompt_horizon import anonymize

#This line will read the JSON data from "input.json" and anonymize only the values.
anonymized_json, map_object = anonymize("input.json", anonymize_keys=False)
```

<br>

### De-anonymize JSON

<br>

```python
from prompt_horizon import de_anonymize

#This line will return the de-anonymized JSON object, which should be the same as the original input JSON.
deanonymized_json = de_anonymize(anonymized_json, map_object=map_object)
```

#### input and output files are supported

```python
from prompt_horizon import de_anonymize

#This will read the anonymized JSON data from "anonymized.json", the mapping object from "map_file.json", de-anonymize the JSON data, and save the de-anonymized JSON to "deanonymized.json".
deanonymized_json = de_anonymize("anonymized.json", map_file_path="map_file.json", output_file_path="deanonymized.json")
```

## License

This project is licensed under the [MIT License](LICENSE).
arraytool 0.1.5
基于numpy的Series及DataFrame数据结构

# arraytool

## 介绍

基于numpy的Series及DataFrame数据结构。

arraytool包中对应于Series及DataFrame的数据类分别为ArraySeries及ArrayFrame，两者同Series及DataFrame之间可方便地进行转换。

## 安装

```python
pip install arraytool
```

## 引入

```python
import arraytool
from arraytool import ArraySeries, ArrayFrame
```

## ArraySeries

### 构造

```python
>>> s1 = ArraySeries(['a','bb','ccc'])
>>> s1
0      a
1     bb
2    ccc
dtype: object
```

### 取值

```python
>>> s1[2]
'ccc'
>>> s1[:2]
0     a
1    bb
dtype: object
```

### 使用索引

```python
>>> s2 = ArraySeries([2,3,4,5],list('aabc'))
>>> s2.iloc[:2]
a    2
a    3
dtype: object
>>> s2.loc['a']
a    2
a    3
dtype: object
>>> s2.loc['b']
4
>>> s2.loc[list('ab')]
a    2
a    3
b    4
dtype: object
```

## ArrayFrame

### 构造

```python
>>> af = ArrayFrame()
>>> af['A'] = list('abcd')
>>> af['B'] = range(4)
>>> af['C'] = [True,True,False,False]
>>> af
   A  B      C
0  a  0   True
1  b  1   True
2  c  2  False
3  d  3  False
```

### 取值

```python
>>> af[list('BC')]
   B      C
0  0   True
1  1   True
2  2  False
3  3  False
```

### 使用索引

#### iloc索引

```python
>>> af.iloc[0,0]
'a'
>>> af.iloc[0]
   A  B     C
0  a  0  True
```

#### loc索引

```python
>>> af.set_index(index_cols='A')
>>> af
   A  B      C
A             
a  a  0   True
b  b  1   True
c  c  2  False
d  d  3  False
>>> af.loc['a','C']
True
>>> af.loc[list('bd'),list('AC')]
   A      C
A          
b  b   True
d  d  False
```

#### ix索引

类R语言data.frame的索引语法，使用pandas弃用的ix索引器。

```python
>>> af.ix[2,'B']
2
>>> af.ix[:2,list('AB')]
   A  B
A      
a  a  0
b  b  1
```