Skip to content

Commit e75fd3b

Browse files
authored
Update NN_trainer.py
1 parent 5c44b12 commit e75fd3b

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

utils/NN_trainer.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,29 @@ def __repr__(self):
4040
"""
4141
return "Hello, I am a neural net trainer!"
4242

43-
def read_csv(self, file):
43+
def read_csv(self, file,**kargs):
4444
"""
45-
Reads a CSV file into a Pandas DataFrame
45+
Reads a CSV file into a Pandas DataFrame
46+
You can use all the usual read_csv keywords
47+
e.g. reading only first few rows or choosing a specific delimiter
4648
"""
4749
from pandas import read_csv
4850

49-
df = read_csv(file)
51+
df = read_csv(file,**kargs)
52+
self.df = df
53+
54+
return self.df
55+
56+
def read_html(self, url,**kargs):
57+
"""
58+
Reads a HTML table into the internal (Pandas) DataFrame
59+
(For now) this only works for a single table on the HTML page.
60+
"""
61+
from pandas import read_html
62+
63+
df = read_html(url,**kargs)[0]
64+
if 'Unnamed: 0' in df.columns:
65+
df.drop('Unnamed: 0',axis=1,inplace=True)
5066
self.df = df
5167

5268
return self.df
@@ -580,4 +596,4 @@ def model_in_plain_english(self):
580596
print("Activation function:", d[i]["config"]["activation"])
581597
print("-" * 40)
582598
print(f"In total, there are {total_param} parameters in this model!")
583-
print()
599+
print()

0 commit comments

Comments
 (0)