-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpandas.py
39 lines (33 loc) · 906 Bytes
/
pandas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from typing import Callable, Optional
import pandas as pd
from .geodraw import geoBrazilUFDrawNetwork
def _draw(
df: pd.DataFrame,
decorator: Callable,
src_col: Optional[str] = None,
dest_col: Optional[str] = None,
ij_col: Optional[str] = None,
jk_col: Optional[str] = None,
**kwargs,
):
df_reindexed = df.set_index([src_col, dest_col])
try:
ij = df_reindexed[ij_col].to_dict()
except KeyError:
ij = {}
try:
jk = df_reindexed[jk_col].to_dict()
except KeyError:
jk = {}
return decorator(ij, jk, **kwargs)
def geoBrazilUFDrawDataframe(
df: pd.DataFrame,
src_col: Optional[str] = None,
dest_col: Optional[str] = None,
ij_col: Optional[str] = None,
jk_col: Optional[str] = None,
**kwargs,
):
return _draw(
df, geoBrazilUFDrawNetwork, src_col, dest_col, ij_col, jk_col, **kwargs
)