def import_fangraphs_pitching(self, table, start, end, cache=False): if cache: from pybaseball import cache cache.enable() data = pitching(start, end) data.to_sql(table, self.db_connection.get_connection(), if_exists='append')
def import_statcast(self, table, start, end, team=None, verbose=True, cache=False): if cache: from pybaseball import cache cache.enable() if team is not None: data = statcast(start, end, team, verbose) else: data = statcast(start, end, verbose) data.to_sql(table, self.db_connection.get_connection(), if_exists='append')
def test_cache_enable() -> None: enable_mock = MagicMock() with patch('pybaseball.cache.config.enable', enable_mock): cache.enable() enable_mock.assert_called_once_with(True)
import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import pybaseball as pyb import numpy as np from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_absolute_error from pybaseball import cache cache.enable() fig, ax = plt.subplots(figsize=(12, 7)) """ #creating the df df = pd.DataFrame({ 'hits_last_year': [120, 180, 105, 133, 150], 'abs_last_year': [400, 560, 450, 505, 490], 'hits_next_year': [127, 170, 110, 128, 145]}) #printing the df print(df.head()) #styling the graph sns.set_style('whitegrid') ax.set_title('Projecting Hits') ax.set_ylabel('Projected Hits') ax.set_xlabel('Last Years Hits') sns.regplot(data = df, x = 'hits_last_year', y = 'hits_next_year') #plt.show()