Metadata-Version: 2.4
Name: Pychemist
Version: 0.0.5
Summary: Transform raw data into insights.
Author-email: Jeroen van Raak <j.j.f.vanraak@uva.nl>
License: Copyright (c) 2025 Jeroen van Raak
        
        MIT License
        
        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.
        
Project-URL: Homepage, https://github.com/vanraak/pychemist
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas>=2.0
Requires-Dist: statsmodels
Requires-Dist: scipy
Dynamic: license-file

# Pychemist

The Alchemist of Data Science

**Transform raw data into insights.**

Pychemist is a lightweight Python library designed to simplify and enrich your data science workflow. Inspired by the transformation mindset of an alchemist, it helps you turn raw data into golden insights. Pychemist replaces complex, repetitive code with a clean and intuitive syntax that streamlines data cleaning, transformation, and preparation to reveal clear insights. It also enables clean and well-structured presentation of results, making it easier to communicate findings effectively.

---

## Features

- Create lagged or lead variables for time-series and panel data
- Run quick, readable t-tests on treatment groups
- Filter model summaries to hide fixed effects
- Conditional mutation of DataFrames
- Pandas accessor (`.chem`) for fluent, chainable workflows

## Installation

```bash
pip install pychemist
```

## Usage
```python
import pychemist as chem
```

# Example 1: Conditional mutation using the `df.chem.mutate` DataFrame accessor.

Update the `total_assets` for a specific company and year to a given value:

```python
df=df.chem.mutate('company_id == "8ga62sav" & year==2025', "total_assets", 82000000)
```

# Example 2: Conditional mutation using the `df.chem.mutate` DataFrame accessor.

Set the `Promotion` column to `1` for managers who haven't been promoted in `3` or more `years` and have a performance rating of at least `4`; otherwise set it to `0`.

```python
df = df.chem.mutate('YearsSinceLastPromotion >= 3 & JobRole == "Manager" & PerformanceRating >= 4', 'Promotion', 1, 0)
```

# Example 3: Creating lagged variables using the `df.chem.lag` DataFrame accessor.

Create lagged versions of `total assets` and `net income` for each `ticker`, only when the `year` difference is exactly `1`:

```python
df=df.chem.lag(['total assets','net income'],'ticker','year')
```

# Example 4: Creating leading variables using the `df.chem.lead` DataFrame accessor.

Create lead (future) versions of `total assets` and `net income` for each `ticker`, only when the `year` difference is exactly `1`:

```python
df=df.chem.lead(['total assets','net income'],'ticker','year')
```

# Example 5: Creating 2-year lagged variables using the `df.chem.lag` DataFrame accessor.

Create lagged versions of `total assets` and `net income` for each `ticker`, only when the `year` difference is exactly `2`:

```python
df=df.chem.lag(['total assets','net income'],'ticker','year',2)
```

# Example 6: T-test between treated and control groups
```python
chem.ttest(df, variable="outcome", treatment="treated")
```

# Example 7: Model summary without fixed effects
```python
import statsmodels.formula.api as smf
model = smf.ols("y ~ x + C(firm)", data=df).fit()
print(chem.summary_no_fe(model))
```


MIT License
Copyright (c) Jeroen van Raak (2025)
