dataenforce icon indicating copy to clipboard operation
dataenforce copied to clipboard

Type annotations for index & multi-index [feature request]

Open WestXu opened this issue 5 years ago • 5 comments

--which would be rather useful.

Cool project. Thanks.

WestXu avatar Jul 29 '20 06:07 WestXu

Thank you for the suggestion @WestXu

I'll have a look at what can be done and how it can fit into the current syntax. Don't hesitate to elaborate on this feature request if you have a specific idea on how it should work (esp. regarding multi-index).

CedricFR avatar Jul 29 '20 14:07 CedricFR

I'm not professional at exactly how type annotation works in python, buy maybe this syntax is possible:

from dataenforce import Dataset, DataIndex

# index
Dataset[DataIndex["id": int], "name": object, "latitude": float, "longitude": float]

# multiindex
Dataset[DataIndex["date": "timestamp", "id": int], "name": object, "latitude": float, "longitude": float]

WestXu avatar Jul 30 '20 00:07 WestXu

Also consider this:

from dataenforce import Dataset, DataIndex, DataColumns

Dataset[
    "index": DataIndex["date": "timestamp", "id": int], 
    "columns": DataColumns["name": object, "latitude": float, "longitude": float]
]

WestXu avatar Jul 30 '20 00:07 WestXu

Support for pandas Series is appreciated!

qiuwei avatar Mar 02 '21 03:03 qiuwei

Also consider this:

from dataenforce import Dataset, DataIndex, DataColumns

Dataset[
    "index": DataIndex["date": "timestamp", "id": int], 
    "columns": DataColumns["name": object, "latitude": float, "longitude": float]
]

This is a great solution

Marco-Christiani avatar May 06 '22 22:05 Marco-Christiani