pandasnet
pandasnet is a python package build on top of pythonnet.
It provides additional data conversions for pandas, numpy and datetime
Prerequisites
- python 3.6 or higher.
- dotnet.
dotnet also provides scripts to proceed the installation by command line.
Installation
pip install pandasnet
Features
To load the converter you need to import the package once in your python environment. If the dotnet clr isn't started yet through the pytonnet package the import will.
import pandasnet
We construct a simple C# function to test conversion
using System;
using System.Collections.Generic;
namespace LibForTests
{
public class PandasNet
{
public static Dictionary<string, Array> BasicDataFrame(Dictionary<string, Array> df)
=> df;
}
}
We build this function into a library named LibForTests.dll.
We load this library into our python environment then use it.
import clr
import pandasnet # Load the converters
import pandas as pd
from datetime import datetime
# Load your dll
clr.AddReference('LibForTests.dll')
from LibForTests import PandasNet as pdnet
x = pd.DataFrame({
'A': [1, 2, 3],
'B': [1.23, 1.24, 1.22],
'C': ['foo', 'bar', 'other'],
'D': [datetime(2021, 1, 22), datetime(2021, 1, 23), datetime(2021, 1, 24)]
})
y = pdnet.BasicDataFrame(x)
print(y)
Below an exhausitve list of supported data convertions.
Python -> .Net
| Python | .Net |
|---|---|
| datetime.datetime | DateTime |
| datetime.date | DateTime |
| datetime.timedelta | TimeSpan |
| datetime.time | TimeSpan |
| numpy.ndarray(dtype=bool_) | bool[] |
| numpy.ndarray(dtype=int8) | sbyte[] |
| numpy.ndarray(dtype=int16) | short[] |
| numpy.ndarray(dtype=int32) | int[] |
| numpy.ndarray(dtype=int64) | long[] |
| numpy.ndarray(dtype=uint8) | byte[] |
| numpy.ndarray(dtype=uint16) | ushort[] |
| numpy.ndarray(dtype=uint32) | uint[] |
| numpy.ndarray(dtype=uint64) | ulong[] |
| numpy.ndarray(dtype=float32) | float[] |
| numpy.ndarray(dtype=float64) | double[] |
| numpy.ndarray(dtype=datetime64) | DateTime[] |
| numpy.ndarray(dtype=timedelta64) | TimeSpan[] |
| numpy.ndarray(dtype=str) | string[] |
| pandas._libs.tslibs.timestamps.Timestamp | DateTime |
| pandas._libs.tslibs.timedeltas.TimeDelta | TimeSpan |
| pandas.core.series.Series | Array |
| pandas.core.frame.DataFrame | Dictionary[string, Array] |
.Net -> Python
| .Net | Python |
|---|---|
| DateTime | datetime.datetime |
| TimeSpan | datetime.timedelta |
| bool[] | numpy.ndarray(dtype=bool_) |
| sbyte[] | numpy.ndarray(dtype=int8) |
| short[] | numpy.ndarray(dtype=int16) |
| int[] | numpy.ndarray(dtype=int32) |
| long[] | numpy.ndarray(dtype=int64) |
| byte[] | numpy.ndarray(dtype=uint8) |
| ushort[] | numpy.ndarray(dtype=uint16) |
| uint[] | numpy.ndarray(dtype=uint32) |
| ulong[] | numpy.ndarray(dtype=uint64) |
| float[] | numpy.ndarray(dtype=float32) |
| double[] | numpy.ndarray(dtype=float64) |
| DateTime[] | numpy.ndarray(dtype=datetime64) |
| TimeSpan[] | numpy.ndarray(dtype=timedelta64) |
| Dictionary[string, Array] | pandas.core.frame.DataFrame |
Contributing
Issue tracker: https://github.com/fdieulle/pandasnet/issues
If you want to checkout the project and propose your own contribution, you will need to setup it following few steps:
Create a virtual environment:
python -m venv venv
Activate your virtual environment:
venv/Scripts/activate
Install package dependencies
pip install -r requirements.txt
License
This project is open source under the MIT license.
Release files for pandasnet 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pandasnet-1.0.tar.gz | 16.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pandasnet-1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.7 kB
Release files / pandasnet-1.0.tar.gz
| Download URL | pandasnet-1.0.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
198d36eeaf01e39fe1e08541ad3c4621c5295cf2b8b8f73157d037ab882cd4f6
|
|
BLAKE2b-256 checksum How to use checksums |
fe5d06e9539359ede2923417ee42a4ecc109997560088d4b2acb47a73938508a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / pandasnet-1.0-py3-none-any.whl
| Download URL | pandasnet-1.0-py3-none-any.whl |
|---|---|
| Size | 22.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
190d6a3db816f1faad6b825b078dfa171260cfe5363b4f148f36d66259a6bdf9
|
|
BLAKE2b-256 checksum How to use checksums |
1ef114ad58c85ddf08f1f525f37936d7ae9b312a94bdeb28f0bce2605b48b58a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|