Skip to content

Commit f87351d

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 179288e commit f87351d

25 files changed

+278
-175
lines changed

docs/examples.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
# Examples
22

33
::: examples
4-
5-

docs/user_guide.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ If *TextRDF.dump_rdf* method is called we will have following RDF triples in tri
1111
<Text#1> <title> "Hello, world!" .
1212
<Text#1> <text> "This is a test of Text" .
1313
```
14-

examples/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

examples/scripts/a0.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
TestDF = typing.NewType("TestDF", pd.DataFrame)
1515
TestDF.columns = ["a"]
1616

17+
1718
@pf.register_dataframe_method
1819
def a0(df: pd.DataFrame) -> TestDF:
1920
"""
@@ -22,7 +23,7 @@ def a0(df: pd.DataFrame) -> TestDF:
2223
# ipdb.set_trace()
2324
print("a0")
2425
return pd.DataFrame(df)
25-
#return df
26+
# return df
2627

2728

2829
if __name__ == "__main__":
@@ -39,5 +40,5 @@ def a0(df: pd.DataFrame) -> TestDF:
3940
# ipdb.set_trace()
4041
print(df1.describe())
4142

42-
pyjviz.save_dot(show_objects=True, popup_output = True)
43-
#pyjviz.save_dot(show_objects=True, popup_output = False)
43+
pyjviz.save_dot(show_objects=True, popup_output=True)
44+
# pyjviz.save_dot(show_objects=True, popup_output = False)

examples/scripts/a00.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ def a0(df: pd.DataFrame) -> TestDF:
3535

3636
t = pyjviz.Text("a0", inspect.getsource(a0))
3737
t.back.dump_rdf()
38-
38+
3939
print(df1.describe())
4040
print(inspect.getsource(a0))
41-
41+
4242
pyjviz.save_dot(show_objects=False)

examples/scripts/a2.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,40 @@
77
import typing
88
import pandas as pd
99

10-
TestDF = typing.NewType('TestDF', pd.DataFrame)
11-
TestDF.columns = ['a']
10+
TestDF = typing.NewType("TestDF", pd.DataFrame)
11+
TestDF.columns = ["a"]
12+
1213

1314
@pf.register_dataframe_method
1415
def a0(df: pd.DataFrame) -> TestDF:
1516
print("a0")
16-
#return pd.DataFrame(df)
17-
#ret = df.shift()
18-
ret = df; ret['a'] += 1
19-
if 'b' in ret.columns:
20-
ret = ret.drop('b', axis = 1, inplace = False)
17+
# return pd.DataFrame(df)
18+
# ret = df.shift()
19+
ret = df
20+
ret["a"] += 1
21+
if "b" in ret.columns:
22+
ret = ret.drop("b", axis=1, inplace=False)
2123
return ret
22-
24+
25+
2326
if __name__ == "__main__":
2427
print(TestDF, TestDF.__name__, TestDF.__supertype__)
2528
print(TestDF.columns)
2629

2730
if 1:
2831
# NB: fix bug when projection is used
29-
df = pd.DataFrame({'a': range(10)})
30-
df['b'] = df.a
32+
df = pd.DataFrame({"a": range(10)})
33+
df["b"] = df.a
3134
else:
32-
df = pd.DataFrame({'a': range(10), 'b': range(10)})
33-
34-
#ipdb.set_trace()
35+
df = pd.DataFrame({"a": range(10), "b": range(10)})
36+
37+
# ipdb.set_trace()
3538
with pyjviz.CB("c"):
3639
df0 = df.a0()
3740
df1 = df.a0().a0()
3841
df2 = df.a0()
3942

40-
#ipdb.set_trace()
43+
# ipdb.set_trace()
4144
print(df1.describe())
4245

43-
pyjviz.save_dot(vertical = False, show_objects = True)
46+
pyjviz.save_dot(vertical=False, show_objects=True)

examples/scripts/dirty-clean1.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,36 @@
88
import pyjviz
99

1010
if __name__ == "__main__":
11-
1211
if 1:
1312
url = "https://github.com/pyjanitor-devs/pyjanitor/blob/dev/examples/notebooks/dirty_data.xlsx?raw=true"
14-
dirty = pd.read_excel(url, engine = 'openpyxl')
13+
dirty = pd.read_excel(url, engine="openpyxl")
1514
else:
1615
dirty = pd.read_excel("../data/dirty_data.xlsx")
17-
16+
1817
print(dirty)
1918

2019
with pyjviz.CB("from_dirty_to_clean") as c:
21-
clean = (dirty
22-
.clean_names()
23-
.dropna(axis='columns', how='all')
24-
.dropna(axis='rows', how='all')
25-
.rename(columns={"%_allocated": "percent_allocated", "full_time_": "full_time"})
26-
.assign(certification = lambda df: df.certification.combine_first(df.certification_1))
27-
.drop(columns='certification_1'))
28-
clean = clean.assign(hire_date1 = clean.hire_date) # , hire_date = pd.to_datetime(clean.hire_date, unit='D', origin='1899-12-30'))
29-
20+
clean = (
21+
dirty.clean_names()
22+
.dropna(axis="columns", how="all")
23+
.dropna(axis="rows", how="all")
24+
.rename(
25+
columns={
26+
"%_allocated": "percent_allocated",
27+
"full_time_": "full_time",
28+
}
29+
)
30+
.assign(
31+
certification=lambda df: df.certification.combine_first(
32+
df.certification_1
33+
)
34+
)
35+
.drop(columns="certification_1")
36+
)
37+
clean = clean.assign(
38+
hire_date1=clean.hire_date
39+
) # , hire_date = pd.to_datetime(clean.hire_date, unit='D', origin='1899-12-30'))
40+
3041
print(clean)
3142

32-
pyjviz.save_dot(vertical = True, show_objects = False)
43+
pyjviz.save_dot(vertical=True, show_objects=False)

examples/scripts/inplace.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,28 @@
77
import typing
88
import pandas as pd
99

10+
1011
@pf.register_dataframe_method
1112
def shift1(df: pd.DataFrame) -> pd.DataFrame:
12-
df = df.shift(axis = 0, fill_value = 0)
13-
#return pd.DataFrame(res_df)
13+
df = df.shift(axis=0, fill_value=0)
14+
# return pd.DataFrame(res_df)
1415
return df
1516

17+
1618
if __name__ == "__main__":
17-
df = pd.DataFrame({'a0': range(10)})
19+
df = pd.DataFrame({"a0": range(10)})
1820
if 0:
19-
for i in range(1,5):
20-
col = f'a{i}'
21+
for i in range(1, 5):
22+
col = f"a{i}"
2123
df[col] = df.a0
2224

23-
#ipdb.set_trace()
25+
# ipdb.set_trace()
2426
with pyjviz.CB("c") as c:
2527
df0 = df.shift1()
2628
df1 = df.shift1().shift1()
2729
df2 = df.shift1()
2830

29-
#ipdb.set_trace()
31+
# ipdb.set_trace()
3032
print(df1.describe())
3133

32-
pyjviz.save_dot(vertical = False, show_objects = True)
34+
pyjviz.save_dot(vertical=False, show_objects=True)

examples/scripts/test-assign.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def a0(df: pd.DataFrame) -> pd.DataFrame:
1414
print("a0")
1515
return pd.DataFrame(df)
16-
#return df
16+
# return df
1717

1818

1919
def test_f(x):

misc/test-bs.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
soup = BeautifulSoup(f, features="xml")
77

88
# Find all <b> tags and replace them with <strong> tags
9-
for a_tag in soup.find_all('a'):
10-
on_click_code = a_tag.attrs.get('xlink:href')
11-
a_tag.parent.attrs['onclick'] = on_click_code.replace('javascript:', '')
12-
a_tag.parent.attrs['cursor'] = 'pointer'
13-
del a_tag.attrs['xlink:href']
14-
del a_tag.attrs['xlink:title']
9+
for a_tag in soup.find_all("a"):
10+
on_click_code = a_tag.attrs.get("xlink:href")
11+
a_tag.parent.attrs["onclick"] = on_click_code.replace("javascript:", "")
12+
a_tag.parent.attrs["cursor"] = "pointer"
13+
del a_tag.attrs["xlink:href"]
14+
del a_tag.attrs["xlink:title"]
1515

16-
for a_tag in soup.find_all('a'):
16+
for a_tag in soup.find_all("a"):
1717
p_tag = a_tag.parent
1818
for c in a_tag.find_all():
1919
p_tag.insert(-1, c)
2020
a_tag.decompose()
21-
21+
2222
# Print the modified HTML output
2323
print(soup.prettify())

0 commit comments

Comments
 (0)