def _get_currency_price(self, bot, update, groups): currency = groups[0] info = self._get_info(currency.replace("_", "-")) text = "Current {} price - ${}".format(info["name"], format_thousands(info["price_usd"], sep=" ")) bot.send_message(chat_id=update.message.chat_id, text=text)
# Look at only observations with revenue per retailer. stats = retailer_stats[~retailer_stats['revenue_per_retailer'].isnull()] # Run a regression of sales per retailer on retailers per 100,000 adults. Y = stats['revenue_per_retailer'] X = stats['retailers_per_100_000'] X = sm.add_constant(X) regression = sm.OLS(Y, X).fit() print(regression.summary()) # Interpret the relationship. beta = regression.params.values[1] statement = """If retailers per 100,000 adults increases by 1, then everything else held constant one would expect revenue per retailer to change by {}. """.format(format_thousands(beta)) print(statement) # Visualize the regression. ax = stats.plot(x='retailers_per_100_000', y='revenue_per_retailer', kind='scatter') abline_plot(model_results=regression, ax=ax) plt.show() #-------------------------------------------------------------------------- # Create a beautiful visualization. #-------------------------------------------------------------------------- # Set chart defaults. plt.style.use('fivethirtyeight')
try: sample_forecast = forecasts[lab_id] timeseries = sample_forecast.resample('Y').sum() timeseries = timeseries.loc[ timeseries.index >= pd.to_datetime('2022-01-01') ] code = lab_id.replace('WA', '') price = labs_data.loc[code]['panel_price'] revenue = timeseries * price total_revenue = revenue.sum() total_samples = timeseries.sum() five_year_forecasts[lab_id] = { 'revenue': revenue.sum(), 'formatted_revenue': format_millions(total_revenue), 'total_samples': total_samples, 'formatted_total_samples': format_thousands(total_samples), 'price': price, } except KeyError: pass # Print 5 year forecasted revenue for each lab. five_year_forecast_data = pd.DataFrame.from_dict(five_year_forecasts, orient='index') five_year_forecast_data.sort_values(by='revenue', ascending=False, inplace=True) print('5 Year Projected Revenue') print(five_year_forecast_data[['formatted_revenue', 'formatted_total_samples', 'price']]) #------------------------------------------------------------------------------ # Future work: What are the prices of required instruments? #------------------------------------------------------------------------------
# Notes and data source. plt.text( -125, 44.25, 'Data Source: Washington State Leaf Traceability Data', ha='left', va='bottom', size=20, color='#000000', ) # Annotate statistics # stats = monthly_plants.loc[monthly_plants.month == date].iloc[0] total_plants = data['total_plants'].sum() if total_plants > 1_000: total_plants = format_thousands(total_plants) total_cultivators = len(data['mme_id'].unique()) plt.text( -124.875, 49.125, month, ha='left', va='bottom', size=22, color='#000000' ) plt.text( -124.875, 48.875, 'Cultivators: %i' % total_cultivators, ha='left',