Skip to content

Commit 8eea9fd

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 0f78aae commit 8eea9fd

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

docs/tracing_ext-demo.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,37 @@
22
import pandas_flavor as pf
33
import time
44

5+
56
@pf.register_dataframe_method
67
def my_method(df: pd.DataFrame) -> pd.DataFrame:
78
print("my_method called")
89
return df.transpose()
910

11+
1012
@pf.register_dataframe_method
1113
def another_method(df: pd.DataFrame, new_col_d) -> pd.DataFrame:
1214
print("another_method called")
1315
for col, v in new_col_d.items():
1416
df[col] = v
1517
return df
1618

19+
1720
class tracer:
1821
@staticmethod
1922
def create_tracer(*args):
2023
return tracer()
21-
24+
2225
def __init__(self):
2326
self.method_name = None
2427
self.start_ts = None
2528
self.end_ts = None
26-
29+
2730
def __enter__(self):
2831
return self
29-
30-
def handle_start_method_call(self,
31-
method_name,
32-
method_signature,
33-
method_args,
34-
method_kwagrs):
32+
33+
def handle_start_method_call(
34+
self, method_name, method_signature, method_args, method_kwagrs
35+
):
3536
self.method_name = method_name
3637
self.start_ts = time.time()
3738
return method_args, method_kwagrs
@@ -46,5 +47,5 @@ def __exit__(self, exc_type, value, traceback):
4647

4748
pf.register.method_call_ctx_factory = tracer.create_tracer
4849
s_df = pd.DataFrame([[i + j for i in range(10)] for j in range(10)])
49-
res_df = s_df.my_method().another_method({'new_col': 'new value'})
50+
res_df = s_df.my_method().another_method({"new_col": "new value"})
5051
print(res_df)

0 commit comments

Comments
 (0)