updated script to no longer pass literal string to read_html using StringIO as behavior is to be deprecated soon in pandas

This commit is contained in:
2024-07-29 11:15:31 -04:00
parent ea275b3f82
commit 542e57de34
6 changed files with 18 additions and 6 deletions
+3 -1
View File
@@ -3,6 +3,8 @@ from fractions import Fraction as frac
import pandas as pd import pandas as pd
import requests import requests
from collections import Counter from collections import Counter
from io import StringIO
def get_data(): def get_data():
# old data from WVLottery.com # old data from WVLottery.com
@@ -17,7 +19,7 @@ def get_data():
# Get web data # Get web data
r = requests.get(url, headers=header) r = requests.get(url, headers=header)
dfs = list(pd.read_html(r.text)) dfs = list(pd.read_html(StringIO(r.text)))
pd.set_option('display.max_rows', None) pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records # Specifies no max rows, otherwise only shows 10 records
df = pd.concat([dfs[0], salvaged], ignore_index=True) df = pd.concat([dfs[0], salvaged], ignore_index=True)
+3 -1
View File
@@ -3,6 +3,8 @@ from fractions import Fraction as frac
import pandas as pd import pandas as pd
import requests import requests
from collections import Counter from collections import Counter
from io import StringIO
def get_data(): def get_data():
url = 'https://wvlottery.com/draw-games/daily-3/?game-analyze=daily-3&what-to-search=historysearch&date-range=-1' url = 'https://wvlottery.com/draw-games/daily-3/?game-analyze=daily-3&what-to-search=historysearch&date-range=-1'
@@ -12,7 +14,7 @@ def get_data():
} }
# Get web data # Get web data
r = requests.get(url, headers=header) r = requests.get(url, headers=header)
dfs = pd.read_html(r.text) dfs = list(pd.read_html(StringIO(r.text)))
pd.set_option('display.max_rows', None) pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records # Specifies no max rows, otherwise only shows 10 records
df = dfs[0] df = dfs[0]
+3 -1
View File
@@ -3,6 +3,8 @@ from fractions import Fraction as frac
import pandas as pd import pandas as pd
import requests import requests
from collections import Counter from collections import Counter
from io import StringIO
def get_data(): def get_data():
# Old data from WVLottery.com # Old data from WVLottery.com
@@ -16,7 +18,7 @@ def get_data():
} }
# Get web data # Get web data
r = requests.get(url, headers=header) r = requests.get(url, headers=header)
dfs = list(pd.read_html(r.text)) dfs = list(pd.read_html(StringIO(r.text)))
pd.set_option('display.max_rows', None) pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records # Specifies no max rows, otherwise only shows 10 records
df = pd.concat([dfs[0], salvaged], ignore_index=True) df = pd.concat([dfs[0], salvaged], ignore_index=True)
+3 -1
View File
@@ -3,6 +3,8 @@ from fractions import Fraction as frac
import pandas as pd import pandas as pd
import requests import requests
from collections import Counter from collections import Counter
from io import StringIO
def get_data(): def get_data():
df_old = pd.read_excel('./excel_lotto_records/lotto_america.xlsx') df_old = pd.read_excel('./excel_lotto_records/lotto_america.xlsx')
@@ -16,7 +18,7 @@ def get_data():
# Get web data # Get web data
r = requests.get(url, headers=header) r = requests.get(url, headers=header)
dfs = list(pd.read_html(r.text)) dfs = list(pd.read_html(StringIO(r.text)))
pd.set_option('display.max_rows', None) pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records # Specifies no max rows, otherwise only shows 10 records
df = pd.concat([dfs[0], salvaged], ignore_index=True) df = pd.concat([dfs[0], salvaged], ignore_index=True)
+3 -1
View File
@@ -17,7 +17,9 @@ def get_data():
} }
# Get web data # Get web data
r = requests.get(url, headers=header) r = requests.get(url, headers=header)
dfs = list(pd.read_html(r.text)) from io import StringIO
dfs = list(pd.read_html(StringIO(r.text)))
pd.set_option('display.max_rows', None) pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records # Specifies no max rows, otherwise only shows 10 records
df = pd.concat([dfs[0], salvaged], ignore_index=True) df = pd.concat([dfs[0], salvaged], ignore_index=True)
+3 -1
View File
@@ -3,6 +3,8 @@ from fractions import Fraction as frac
import pandas as pd import pandas as pd
import requests import requests
from collections import Counter from collections import Counter
from io import StringIO
def get_data(): def get_data():
# previous records which have since been removed from wvlottery.com's database # previous records which have since been removed from wvlottery.com's database
@@ -17,7 +19,7 @@ def get_data():
# Get web data # Get web data
r = requests.get(url, headers=header) r = requests.get(url, headers=header)
dfs = list(pd.read_html(r.text)) dfs = list(pd.read_html(StringIO(r.text)))
pd.set_option('display.max_rows', None) pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records # Specifies no max rows, otherwise only shows 10 records
df = pd.concat([dfs[0], salvaged], ignore_index=True) df = pd.concat([dfs[0], salvaged], ignore_index=True)