def test_seasonalise_weekly(self): dirname, filename = os.path.split(os.path.abspath(__file__)) cl = pd.read_csv(os.path.join(dirname, 'test_weekly.csv'), index_col=0, parse_dates=True, dayfirst=True) seas = transforms.seasonalise_weekly(cl['PET.WCRSTUS1.W']) self.assertEqual( seas[2020].loc[datetime.fromisocalendar( dates.curyear, pd.to_datetime('2020-01-03').isocalendar()[1], 1)], 1066027) self.assertEqual( seas[2020].loc[datetime.fromisocalendar( dates.curyear, pd.to_datetime('2020-01-10').isocalendar()[1], 1)], 1063478) self.assertEqual( seas[2000].loc[datetime.fromisocalendar( dates.curyear, pd.to_datetime('2000-01-07').isocalendar()[1], 1)], 844791) self.assertEqual( seas[2000].loc[datetime.fromisocalendar( dates.curyear, pd.to_datetime('2000-12-29').isocalendar()[1], 1)], 813959)
def test_timespan_args_begin_iso_week_and_thru_iso_week(): """Tests timespan arguments: begin iso week, thru iso week. """ start, end = timespan(begin_str=REF_BEGIN_ISO, thru_str=REF_THRU_ISO) begin = datetime.fromisocalendar(2020, 10, 1).astimezone() thru = datetime.fromisocalendar(2020, 25, 1).astimezone() + timedelta(days=7) assert isinstance(start, datetime) assert start == begin assert isinstance(end, datetime) assert end == thru
def test_event_renders_template(self, default_user): r = self.client.post( "/event", data={ "year": "2020", "week": "1", "hour": "1", "day": "1" }, ) template, context = self.rendered_templates[0] AssertThat(r.status_code).IsEqualTo(200) AssertThat(template.name).IsEqualTo("event.html") AssertThat(context["start_date"]).IsEqualTo( datetime.fromisocalendar(2020, 1, 2).strftime("%Y-%m-%d")) AssertThat(context["start_time"]).IsEqualTo("01:00:00") AssertThat(context["end_time"]).IsEqualTo("02:00:00") AssertThat(r.data).DoesNotContain(b'placeholder="Title" readonly') AssertThat( r.data).DoesNotContain(b'placeholder="Description" readonly') AssertThat(r.data).DoesNotContain(b'placeholder="Location" readonly') AssertThat(r.data).Contains(b'id="start_date" readonly') AssertThat(r.data).DoesNotContain(b'id="start_time" readonly') AssertThat(r.data).Contains(b'id="end_date" readonly') AssertThat(r.data).DoesNotContain(b'id="end_time" readonly') AssertThat(r.data).DoesNotContain( b'onclick="return false;" name="business_hour"') AssertThat(r.data).Contains(b'value="Save"') AssertThat(r.data).Contains(b'value="Delete"')
def _parse_date(spotify_release_date): """For Herbie Hancock alone, I've seen these release_dates: - "1999-01-01" - "2009" - "1980-03" """ # sometime Spotify just gives a year if len(spotify_release_date) == 4: # default to first day of year return datetime.fromisocalendar(int(spotify_release_date), 1, 1) elif len(spotify_release_date) == 7: # default to first day of month return datetime.fromisocalendar(int(spotify_release_date[:4]), int(spotify_release_date[5:7]), 1) else: return datetime.fromisoformat(spotify_release_date)
def get_vaccination_data(data_url, sheet_name, set_date=False, only_sweden=False, needed_columns=None): df_vacc = pd.read_excel(data_url, sheet_name=sheet_name, header=0, engine="openpyxl", keep_default_na=False) # if needed, convert week date to full date, initially set day as Monday if set_date: df_vacc["day"] = 1 df_vacc["date"] = df_vacc.apply(lambda row: dt.fromisocalendar( row["År"], row["Vecka"], row["day"]), axis=1) # We need to calculate values for the population. Don't use the values for just the population eligible for vaccination df_vacc["Andel vaccinerade"] = df_vacc["Andel vaccinerade"].replace( ",", ".", regex=True) df_vacc["Procent vaccinerade"] = ( df_vacc["Andel vaccinerade"].astype(float)) * 100 # need to change 'Sverige' to 'Sweden' df_vacc = df_vacc.replace("| Sverige |", "Sweden") if only_sweden: df_vacc = df_vacc[df_vacc["Region"] == "Sweden"] # have only relevant column if needed if needed_columns: df_vacc = df_vacc[needed_columns] return df_vacc
def test_set_date_pair(): """ Scenario: Set date_start and date_end for both creation and modification. Given: - User has provided valid credentials. When: - Every time cyberint_list_alerts is called. Then: - Ensure dates return match what is needed (correct format) """ from Cyberint import set_date_pair start_time = '2020-12-01T00:00:00Z' end_time = '2020-12-05T00:00:00Z' assert set_date_pair(start_time, end_time, None) == (start_time, end_time) new_range = '3 Days' three_days_ago = datetime.strftime(datetime.now() - timedelta(days=3), DATE_FORMAT) current_time = datetime.strftime(datetime.now(), DATE_FORMAT) assert set_date_pair(start_time, end_time, new_range) == (three_days_ago, current_time) assert set_date_pair(start_time, None, None) == (start_time, datetime.strftime(datetime.now(), DATE_FORMAT)) assert set_date_pair(None, end_time, None) == (datetime.strftime( datetime.fromisocalendar(2020, 2, 1), DATE_FORMAT), end_time)
def pos_to_xarray(posfile: str, weekstart_year: int, weekstart_week: int): if not xarray_enabled: raise EnvironmentError('pos_to_xarray: Unable to import xarray, pos_to_xarray disabled') attrs = {'mission_date': datetime.fromisocalendar(weekstart_year, weekstart_week, 1).strftime('%Y-%m-%d %H:%M:%S')} posdat = _pos_convert(posfile, weekstart_year, weekstart_week) attrs['pos_files'] = {os.path.split(posfile)[1]: [float(posdat.time.values[0]), float(posdat.time.values[-1])]} posdat.attrs = attrs return posdat
def test_constructor_fromisocalendar(self): # GH 30395 expected_timestamp = Timestamp("2000-01-03 00:00:00") expected_stdlib = datetime.fromisocalendar(2000, 1, 1) result = Timestamp.fromisocalendar(2000, 1, 1) assert result == expected_timestamp assert result == expected_stdlib assert isinstance(result, Timestamp)
def test_calculate_days_of_week_calculates_weekdays_correctly(self): now = datetime.now().isocalendar() days_of_week = self.date_time_helper.calculate_days_of_week( now[0], now[1] ) for i in range(1, 8): AssertThat(days_of_week[i - 1]["date"]).IsEqualTo( datetime.fromisocalendar(now[0], now[1], i) .date() .strftime("(%b. %-d)") ) AssertThat(days_of_week[i - 1]["name"]).IsEqualTo( datetime.fromisocalendar(now[0], now[1], i) .date() .strftime("%a") )
def fill_combo_box_with_first_crawl_epochs(): values = list() values.append(('', '')) for epoch in StatisticsView.history.history: epoch_date = datetime.fromtimestamp(epoch.crawl_epoch) dlrobot_birthday = datetime.fromisocalendar(2020, 2, 1) if epoch_date < dlrobot_birthday: epoch_date = dlrobot_birthday values.append((str(epoch.crawl_epoch), epoch_date.strftime("%Y-%m-%d"))) return values
def get_end_date(self): end_date = datetime.fromisocalendar( self.__year, self.__week, self.__day + 1 ) if self.__hour == 23: end_date += timedelta(days=1) end_date = end_date.strftime("%Y-%m-%d") return end_date
def week_dates(week=None, year=None): if not week or not year: week_year = current_week() year = week_year[0] week = week_year[1] return [ datetime.fromisocalendar(year, week, i).date() for i in range(1, 6) ]
def cont_to_date(update, context): user = update.message.from_user logger.info("2: User {} confirmed giving attendance via /Yes".format(user.first_name, update.message.text)) context.bot.send_message(chat_id=update.effective_chat.id, text="😮 Wow that's some enthusiasm there! 😮") TODAY = (datetime.today() + timedelta(hours=8)).strftime("%A, %Y/%m/%d") context.bot.send_message(chat_id=update.effective_chat.id, text="📅 Today is *{}*.".format(TODAY), parse_mode=telegram.ParseMode.MARKDOWN) # context.bot.send_message(chat_id=update.effective_chat.id, text="Which is also time for you to wAkE tHE fK UP 😥😥 \n\njkjk 🥰.".format(TODAY), parse_mode=telegram.ParseMode.MARKDOWN) THIS_YEAR = (datetime.today() + timedelta(hours=8)).isocalendar()[0] THIS_WEEK = (datetime.today() + timedelta(hours=8)).isocalendar()[1] if (datetime.today() + timedelta(hours=8)).isocalendar()[2] < 4: context.bot.send_message(chat_id=update.effective_chat.id, text="jkjk 🥰.\n\n Since it's still *NOT Thurs*, you can select for this week's attendance.", parse_mode=telegram.ParseMode.MARKDOWN) kb = [[telegram.KeyboardButton(datetime.fromisocalendar(THIS_YEAR, THIS_WEEK, 1).strftime("%a, %Y/%m/%d"))], [telegram.KeyboardButton(datetime.fromisocalendar(THIS_YEAR, THIS_WEEK, 3).strftime("%a, %Y/%m/%d"))]] else: context.bot.send_message(chat_id=update.effective_chat.id, text="Since it's *PAST Thurs*, you can indicate for next week's attendance.", parse_mode=telegram.ParseMode.MARKDOWN) kb = [[telegram.KeyboardButton(datetime.fromisocalendar(THIS_YEAR, THIS_WEEK+1, 1).strftime("%a, %Y/%m/%d"))], [telegram.KeyboardButton(datetime.fromisocalendar(THIS_YEAR, THIS_WEEK+1, 3).strftime("%a, %Y/%m/%d"))]] kb_markup = telegram.ReplyKeyboardMarkup(kb, one_time_keyboard=True) update.message.reply_text("✅ Indicate the date you would come for: \n\n Alternatively, you can type in the format 'Day, 'yyyy/mm/dd'", reply_markup=kb_markup, parse_mode=telegram.ParseMode.MARKDOWN) return TIME
def test_timespan_args_week_str_and_thru_str(): """Tests timespan arguments: week_str, thru_str. """ start, end = timespan(week_str=REF_BEGIN_ISO, thru_str=REF_THRU_STR) begin = datetime.fromisocalendar(2020, 10, 1).astimezone() assert isinstance(start, datetime) assert start.isoformat() == begin.isoformat() assert isinstance(end, datetime) assert end.isoformat() == REF_THRU_STR
def date_func(dataset): dataset[["Year", "Week"]] = (dataset["wk"].str.split("w", expand=True).astype(int) ) # break apart week and year dataset["day"] = 1 # set day as Monday dataset.drop(dataset[(dataset["Year"] == 2019)].index, inplace=True) dataset["date"] = dataset.apply( lambda row: dt.fromisocalendar(row["Year"], row["Week"], row["day"]), axis=1) dataset.drop(dataset[(dataset["date"] < "2020-01-31")].index, inplace=True) dataset.drop(columns=["Week", "Year", "day", "wk"], axis=1, inplace=True)
def test_get_week_post_renders_week_template(self, default_user): self.__insert_week() r = self.client.post(f"/{YEAR}/{WEEK}", data=TEST_EVENT) template, context = self.rendered_templates[0] AssertThat(r.status_code).IsEqualTo(200) AssertThat(template.name).IsEqualTo("week.html") AssertThat(context["year_number"]).IsEqualTo(YEAR) AssertThat(context["week_number"]).IsEqualTo(WEEK) for i in range(1, 8): AssertThat(context["days_of_week"][i - 1]["date"]).IsEqualTo( datetime.fromisocalendar(YEAR, WEEK, i) .date() .strftime("(%b. %-d)") ) AssertThat(context["days_of_week"][i - 1]["name"]).IsEqualTo( datetime.fromisocalendar(YEAR, WEEK, i).date().strftime("%a") )
def getAttendance(update, context): user = update.message.from_user logger.info("1/2: User {} has started querying for attendance".format(user.first_name, update.message.text)) context.bot.send_message(chat_id=update.effective_chat.id, text="👇 Please select the date of attendance 👇") TODAY = (datetime.today() + timedelta(hours=8)).strftime("%A, %Y/%m/%d") context.bot.send_message(chat_id=update.effective_chat.id, text="📅 Today is *{}*.".format(TODAY), parse_mode=telegram.ParseMode.MARKDOWN) # context.bot.send_message(chat_id=update.effective_chat.id, text="Which is also time for you to wAkE tHE fK UP 😥😥 \n\njkjk 🥰.".format(TODAY), parse_mode=telegram.ParseMode.MARKDOWN) THIS_YEAR = (datetime.today() + timedelta(hours=8)).isocalendar()[0] THIS_WEEK = (datetime.today() + timedelta(hours=8)).isocalendar()[1] if (datetime.today() + timedelta(hours=8)).isocalendar()[2] < 4: context.bot.send_message(chat_id=update.effective_chat.id, text="jkjk 🥰.\n\n Since it's still *NOT Thurs*, I've prepared options for this week's attendance.", parse_mode=telegram.ParseMode.MARKDOWN) kb = [[telegram.KeyboardButton(datetime.fromisocalendar(THIS_YEAR, THIS_WEEK, 1).strftime("%Y/%m/%d"))], [telegram.KeyboardButton(datetime.fromisocalendar(THIS_YEAR, THIS_WEEK, 3).strftime("%Y/%m/%d"))]] else: context.bot.send_message(chat_id=update.effective_chat.id, text="Since it's *PAST Thurs*, I've prepared options for next week's attendance.", parse_mode=telegram.ParseMode.MARKDOWN) kb = [[telegram.KeyboardButton(datetime.fromisocalendar(THIS_YEAR, THIS_WEEK+1, 1).strftime("%Y/%m/%d"))], [telegram.KeyboardButton(datetime.fromisocalendar(THIS_YEAR, THIS_WEEK+1, 3).strftime("%Y/%m/%d"))]] kb_markup = telegram.ReplyKeyboardMarkup(kb, one_time_keyboard=True) update.message.reply_text("✅ Indicate the date you would come for: \n\n Alternatively, you can type in the format 'yyyy/mm/dd' or type /No to cancel.", reply_markup=kb_markup, parse_mode=telegram.ParseMode.MARKDOWN) return GETATT1
def schedule(request): def get_date(req_day): if req_day: year, month = (int(x) for x in req_day.split('-')) return date(year, month, day=1) return timezone.now() d = get_date(request.GET.get('day', None)).isocalendar() year, week = d[0], d[1] if d[2] == 7: week = week + 1 final_week = date(year, 12, 31).isocalendar()[1] weeks = [] for n in range(week - 3, week + 5): new_week = [] if n > final_week: n = n - final_week if n == 1: sunday = timezone.make_aware( datetime.fromisocalendar(year, final_week, 7)) year = year + 1 else: sunday = timezone.make_aware( datetime.fromisocalendar(year, n - 1, 7)) new_week.append(sunday) for i in range(1, 7): day = timezone.make_aware(datetime.fromisocalendar(year, n, i)) new_week.append(day) weeks.append(new_week) meals = Meal.objects.filter(user=request.user, date__range=[weeks[0][0], weeks[-1][-1]]) context = { "weeks": weeks, "meals": meals, "today": timezone.make_aware(datetime.fromisocalendar(d[0], d[1], d[2])) } return render(request, 'schedule/calendar.html', context)
def test_timespan_args_begin_iso_week_and_thru_str_missing(): """Tests timespan arguments: begin iso week, thru_str missing. """ start, end = timespan(begin_str=REF_BEGIN_ISO) begin = datetime.fromisocalendar(2020, 10, 1).astimezone() end_now = datetime.now(tz.tzlocal()) assert isinstance(start, datetime) assert start == begin assert isinstance(end, datetime) assert end.isoformat()[0:18] == end_now.isoformat()[0:18]
def test_timespan_args_week_str_and_begin_str(): """Tests timespan arguments: week_str, begin_str. """ start, end = timespan(week_str=REF_THRU_ISO, begin_str=REF_BEGIN_STR) thru = datetime.fromisocalendar(2020, 25, 1).astimezone() + timedelta(days=7) assert isinstance(start, datetime) assert start.isoformat() == REF_BEGIN_STR assert isinstance(end, datetime) assert end.isoformat() == thru.isoformat()
def smrmsg_to_xarray(smrmsgfile, logfile=None, weekstart_year=None, weekstart_week=None): """ Convert an smrmsg file to an xarray Dataset object, containing the metadata and variables that we are interested in. Parameters ---------- smrmsgfile: str, full file path to the smrmsg file (SBET uncertainty file) logfile: str, full file path to the sbet export log file weekstart_year: int, if you aren't providing a logfile, must provide the year of the sbet here weekstart_week: int, if you aren't providing a logfile, must provide the week of the sbet here Returns ------- dat: xarray Dataset, data and attribution from the sbet relevant to our survey processing """ if logfile is not None: attrs = get_export_info_from_log(logfile) if attrs['mission_date'] is None: raise ValueError( 'Provided log does not seem to have a mission date: {}'.format( logfile)) weekstart_year, weekstart_week, weekstart_day = attrs[ 'mission_date'].isocalendar() elif weekstart_year is not None and weekstart_week is not None: attrs = {} else: raise ValueError( 'Expected either a log file to be provided or a year/week representing the start of the week.' ) smrmsgdat = _smrmsg_convert(smrmsgfile, weekstart_year, weekstart_week) if smrmsgdat is not None: smrmsg_rate = int(1 / (smrmsgdat.time[1] - smrmsgdat.time[0])) final_attrs = {} if 'mission_date' not in attrs: attrs = { 'mission_date': datetime.fromisocalendar(weekstart_year, weekstart_week, 1).strftime('%Y-%m-%d %H:%M:%S') } final_attrs['mission_date'] = attrs['mission_date'] final_attrs['logging rate (hz)'] = smrmsg_rate final_attrs['source_file'] = smrmsgfile smrmsgdat.attrs = final_attrs else: smrmsgdat = None return smrmsgdat
def test_get_checkouts_ordered_by_due_date(client): client.post(f"{API_BASE_PATH}/users/1/checkout/1") client.post(f"{API_BASE_PATH}/users/3/checkout/2") client.post(f"{API_BASE_PATH}/users/1/checkout/3") client.post(f"{API_BASE_PATH}/users/2/checkout/4") client.post(f"{API_BASE_PATH}/users/3/checkout/5") client.post(f"{API_BASE_PATH}/users/4/checkout/6") response = client.get(f"{API_BASE_PATH}/checkouts") data = json.loads(response.data) previous_due_date = datetime.fromisocalendar(3000, 1, 1) for checkout in data: assert previous_due_date > datetime.strptime( checkout["due_date"], "%a, %d %b %Y %H:%M:%S %Z")
def test_timespan_args_begin_str_missing_and_thru_iso_week(): """Tests timespan arguments: begin_str missing, thru iso week. """ start, end = timespan(thru_str=REF_THRU_ISO) start_first = datetime(2000, 1, 1, 0, 0).astimezone() thru = datetime.fromisocalendar(2020, 25, 1).astimezone() + timedelta(days=7) assert isinstance(start, datetime) assert start.isoformat() == start_first.isoformat() assert isinstance(end, datetime) assert end == thru
def test_fromisocalendar_date_datetime(self, dt): isocalendar = dt.isocalendar() dt_rt = datetime.fromisocalendar(*isocalendar) # Only the date portion of the datetime survives a round trip. d = dt.date() d_rt = dt_rt.date() self.assertEqual(d, d_rt) # .fromisocalendar() should always return a datetime at midnight t = time(0) t_rt = dt_rt.time() self.assertEqual(t, t_rt)
def fromisoweek(week_string): """Calculates the datetime from the specified ISO Week string. Args: week_string: The ISO week string. Returns: The datetime object. """ pattern_isoweek = r'^\d{4}-W\d{2}$' if re.search(pattern_isoweek, week_string): year = int(week_string[:4]) week = int(week_string[-2:]) return datetime.fromisocalendar(year, week, 1).astimezone() return None
def add_meal(request, year, week, day): if request.method == 'POST': meal_form = MealForm(request.user, request.POST) if meal_form.is_valid(): meal = meal_form.save(False) meal.user = request.user meal.date = timezone.make_aware( datetime.fromisocalendar(year, week, day)) meal.save() return redirect('calendar') else: meal_form = MealForm(request.user) context = { 'meal_form': meal_form, } return render(request, 'schedule/add_meal.html', context)
def seasonalise_weekly(df, freq='W'): """ Edge case for handling weekly data - eg DOE where we need to tweak the standard seasonalise() method. :param df: :return: """ if isinstance(df, pd.Series): df = pd.DataFrame(df) df = pd.merge(df, df.index.isocalendar(), left_index=True, right_index=True) df = df.groupby([df.week, df.year]).mean()[df.columns[0]].unstack() # when converting back to date format, some years don't have week 53 so drop for now if 53 in df.index and pd.to_datetime( '%s-12-31' % dates.curyear).isocalendar()[1] == 52: df = df.drop(53) df.index = df.index.map(lambda x: datetime.fromisocalendar(2021, x, 1)) return df
def test_passage_export_filters(self, payload_version: PayloadVersion): date = datetime.fromisocalendar(2019, 11, 1) # create data for 3 cameras baker.make( 'passage.PassageHourAggregation', camera_id=cycle(range(1, 4)), camera_naam=cycle(f'Camera: {i}' for i in range(1, 4)), date=date, year=date.year, week=date.isocalendar()[1], hour=1, _quantity=100, ) api_version = to_api_version(payload_version) url = reverse(f'{api_version}:passage-export') response = self.client.get(url, dict(year=2019, week=12), HTTP_AUTHORIZATION='Token foo') assert response.status_code == 200 lines = [x for x in response.streaming_content] assert len(lines) == 0 response = self.client.get(url, dict(year=2019, week=11), HTTP_AUTHORIZATION='Token foo') assert response.status_code == 200 lines = [x for x in response.streaming_content] # Expect the header and 3 lines assert len(lines) == 4 response = self.client.get(url, dict(year=2019), HTTP_AUTHORIZATION='Token foo') assert response.status_code == 200 lines = [x for x in response.streaming_content] # Expect the header and 3 lines assert len(lines) == 4
# source quarantine data from archival CSV df_quarantine = pd.read_csv(os.path.join(CSV_FOLDER, 'stats-weekly-archive.csv'), index_col='week') df_quarantine = df_quarantine[[ 'week.sent_to.quarantine', 'week.src.quarantine' ]] df_quarantine = df_quarantine.replace({0: None}).astype('Int64') merged = df_d_1.join(df_d_2).join(df_i_1).join(df_i_2).join(df_i_3).join( df_i_4).join(df_quarantine) week_dates = {'week': [], 'date': [], 'date.to': []} for x in merged.index: year, week = x.split('-') week_start = datetime.fromisocalendar(int(year), int(week), 1).date() week_end = datetime.fromisocalendar(int(year), int(week), 7).date() week_dates['week'].append(x) week_dates['date'].append(week_start) week_dates['date.to'].append(week_end) merged = merged.join(pd.DataFrame(data=week_dates).set_index('week')) merged = merged.reindex( [ # sort 'date', 'date.to', 'week.confirmed', 'week.investigated', 'week.healthcare', 'week.healthcare.male', 'week.healthcare.female', 'week.rhoccupant', 'week.loc.family', 'week.loc.work', 'week.loc.school', 'week.loc.hospital', 'week.loc.otherhc', 'week.loc.rh', 'week.loc.prison', 'week.loc.transport', 'week.loc.shop', 'week.loc.restaurant', 'week.loc.sport', 'week.loc.gathering_private', 'week.loc.gathering_organized',
wastewater_data = pd.read_csv( "https://datagraphics.dckube.scilifelab.se/api/dataset/65f19e61386a4a039aa798010ca42469.csv", sep=",", ) wastewater_data["year"] = (wastewater_data["week"].str[:4]).astype(int) wastewater_data["week_no"] = wastewater_data["week"].str[-3:] wastewater_data["week_no"] = wastewater_data["week_no"].str.replace("*", "", regex=True) wastewater_data["week_no"] = ( wastewater_data["week_no"].str.replace("-", "", regex=True) ).astype(int) # set the date to the start of the week (Monday) wastewater_data["day"] = 1 wastewater_data["date"] = wastewater_data.apply( lambda row: dt.fromisocalendar(row["year"], row["week_no"], row["day"]), axis=1 ) # colours for plot colours = px.colors.diverging.RdBu # Below sets a dataset for each city. Need to add to it if more places are added # Will also need to add in a go.Scatter trace in the fig (no change needed to layout) bromma_wwtp_jarva = wastewater_data[ (wastewater_data["wwtp"] == "Bromma WWTP, Järva Inlet") ] bromma_wwtp_riksby = wastewater_data[ (wastewater_data["wwtp"] == "Bromma WWTP, Riksby Inlet") ] bromma_wwtp_hasselby = wastewater_data[ (wastewater_data["wwtp"] == "Bromma WWTP, Hässelby Inlet")