semvec/pypi-packages huggingface dataset:
yl 0.0.6
Get dictionaries from other objects
License: apache-2.0

# yl
Get dictionaries from other objects

To install:	```pip install yl```

## Overview
The `yl` package provides a set of utilities to convert data structures into more usable dictionary formats, particularly focusing on data extraction and transformation from pandas DataFrames. It also includes functionalities to safely read JSON files and merge dictionaries with customizable strategies.

## Features

### DataFrame to Dictionary Conversion
- **`keyval_df`**: Convert a DataFrame into a dictionary using one column for keys and another for values.
- **`df_to_dict_list`**: Transform a DataFrame into a list of dictionaries, with options to specify which columns to use for keys and values.
- **`df_to_keyed_dict`**: Convert a DataFrame into a dictionary, using one column as keys and applying an optional transformation function to the rest of the data in each row.

### JSON Utilities
- **`json_str_file`**: Load and parse a JSON file into a Python object.
- **`safe_json_str_file`**: Safely read a JSON file, ensuring the file is properly closed after reading.

### Dictionary Utilities
- **`filter_dicts_by_keys`**: Filter a list of dictionaries, retaining only specified keys.
- **`merge_dicts`**: Merge multiple dictionaries into one, with a customizable strategy for handling key collisions.

## Usage Examples

### Convert DataFrame to Dictionary
```python
import pandas as pd
df = pd.DataFrame({
    'id': [1, 2, 3],
    'name': ['Alice', 'Bob', 'Charlie'],
    'age': [25, 30, 35]
})
result = df_to_keyed_dict(df, 'id')
print(result)
# Output: {1: {'name': 'Alice', 'age': 25}, 2: {'name': 'Bob', 'age': 30}, 3: {'name': 'Charlie', 'age': 35}}
```

### Read JSON File Safely
```python
json_data = safe_json_str_file('example.json')
print(json_data)
# Assuming 'example.json' contains '{"key": "value"}'
# Output: {'key': 'value'}
```

### Filter List of Dictionaries
```python
dict_list = [{'name': 'Alice', 'age': 25, 'city': 'New York'}, {'name': 'Bob', 'age': 30, 'city': 'Chicago'}]
filtered = filter_dicts_by_keys(dict_list, ['name', 'city'])
print(filtered)
# Output: [{'name': 'Alice', 'city': 'New York'}, {'name': 'Bob', 'city': 'Chicago'}]
```

### Merge Dictionaries with Custom Strategy
```python
d1 = {'name': 'Alice', 'age': 25}
d2 = {'name': 'Bob', 'city': 'New York'}
merged = merge_dicts(d1, d2, merge_strategy=lambda values: ', '.join(map(str, values)))
print(merged)
# Output: {'name': 'Alice, Bob', 'age': 25, 'city': 'New York'}
```

## Documentation
Each function in the `yl` package is documented with Python docstrings, providing detailed descriptions of their purpose, parameters, return values, and examples. This documentation can be accessed using the help function in Python, e.g., `help(df_to_keyed_dict)`.
yw 0.0.9
Audio Layers
License: apache-2.0

# yw
Audio Layers

To install:	```pip install yw```

## Overview
The `yw` package provides a comprehensive suite of tools for audio processing and manipulation in Python. It leverages popular libraries such as `numpy`, `librosa`, `soundfile`, and `matplotlib` to offer functionalities like audio file conversion, resampling, waveform manipulation, and audio visualization.

## Features
- **Audio Conversion**: Convert audio files to different formats and sample rates using `convert_to_wav`.
- **Waveform Manipulation**: Functions to ensure mono audio, resample audio, and manipulate waveforms with operations like adding silence.
- **Audio Information Extraction**: Retrieve detailed information from audio files, such as duration, sample rate, and format-specific data.
- **Audio Visualization**: Plot waveforms and spectrograms to visualize audio data.
- **Sound Object**: A `Sound` class that encapsulates audio data along with utility methods for easy manipulation and analysis.

## Usage Examples

### Converting Audio Files to WAV
Convert any audio file format supported by `ffmpeg` to WAV format with a specified sample rate:
```python
from yw import convert_to_wav

convert_to_wav('input.mp3', 'output.wav', sample_rate=44100)
```

### Extracting Audio File Information
Get detailed information from a WAV file:
```python
from yw import sound_file_info_dict

info = sound_file_info_dict('example.wav')
print(info)
```

### Plotting a Waveform
Visualize the waveform of an audio file:
```python
from yw import display_sound

display_sound('path/to/audio.wav')
```

### Working with the Sound Class
Create a `Sound` object from a file, manipulate it, and save the output:
```python
from yw import Sound

sound = Sound.from_file('input.wav')
sound.resample(new_sr=22050)
sound.save_to_wav('output_resampled.wav')
```

### Mixing Audio
Mix two audio files into one by adjusting their relative weights:
```python
from yw import Sound

sound1 = Sound.from_file('audio1.wav')
sound2 = Sound.from_file('audio2.wav')
sound1.mix_in(sound2, weight=0.5)
sound1.save_to_wav('mixed_output.wav')
```

## Documentation
Each function and class in the `yw` package comes with detailed docstrings that provide more information on their usage and parameters. Here are some key functions/classes and their purposes:

- `convert_to_wav(source_file, target_file=None, sample_rate=44100)`: Convert an audio file to WAV format.
- `sound_file_info_dict(filepath)`: Retrieve a dictionary containing information about the audio file.
- `display_sound(filepath)`: Plot and play an audio file.
- `Sound`: A class that represents an audio signal, with methods like `from_file`, `resample`, `mix_in`, and `save_to_wav` for handling audio data.

For more detailed information, refer to the docstrings provided within the code.