2021年3月26日星期五

How to identify dates where a certain condition is met? [In python]

I have a data frame with the min, max prices for each hour of a day. The duration of the dataset is about one year. I have attached an example. You can run the code snippet to generate the table. Sorry I am new to Stackoverflow, I don't how to insert tables here yet.

I want to isolate the dates where Consume(Min) price < 0 for atleast 4 times, between 9h to 16h for that date {lets name this condition 1}. I want a output which consists of all the dates (with all 24 hrs) where condition 1 is met.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  <html><head><title></title>  <meta http-equiv="Content-Style-Type" content="text/css">  <style type="text/css"><!--  body {    margin: 5px 5px 5px 5px;    background-color: #ffffff;  }  /* ========== Text Styles ========== */  hr { color: #000000}  body, table /* Normal text */  {   font-size: 10pt;   font-family: 'Courier New';   font-style: normal;   font-weight: normal;   color: #000000;   text-decoration: none;  }  span.rvts1 /* Heading */  {   font-family: 'Arial';   font-weight: bold;   color: #0000ff;  }  span.rvts2 /* Subheading */  {   font-family: 'Arial';   font-weight: bold;   color: #000080;  }  span.rvts3 /* Keywords */  {   font-family: 'Arial';   font-style: italic;   color: #800000;  }  a.rvts4, span.rvts4 /* Jump 1 */  {   color: #008000;   text-decoration: underline;  }  a.rvts5, span.rvts5 /* Jump 2 */  {   font-family: 'Arial';   color: #008000;   text-decoration: underline;  }  /* ========== Para Styles ========== */  p,ul,ol /* Paragraph Style */  {   text-align: left;   text-indent: 0px;   padding: 0px 0px 0px 0px;   margin: 0px 0px 0px 0px;  }  .rvps1 /* Centered */  {   text-align: center;  }  --></style>  </head>  <body>    <p><br></p>  <div><table width="100%" border=1 cellpadding=1 cellspacing=2 style="background-color: #ffffff;">  <tr valign=top>  <td style="border-style: inset;">  <p><span class=rvts1>Date (CET)</span></p>  </td>  <td style="border-style: inset;">  <p><span class=rvts1>Consume (Min)</span></p>  </td>  <td style="border-style: inset;">  <p><span class=rvts1>Feed (Max)</span></p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;"><br>  </td>  <td style="border-style: inset;">  <p>EUR</p>  </td>  <td style="border-style: inset;">  <p>EUR</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[24/03/2021 11:00]</p>  </td>  <td style="border-style: inset;">  <p>-159.02</p>  </td>  <td style="border-style: inset;">  <p>-159.02</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[24/03/2021 12:00]</p>  </td>  <td style="border-style: inset;">  <p>-159</p>  </td>  <td style="border-style: inset;">  <p>-53.89</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[24/03/2021 13:00]</p>  </td>  <td style="border-style: inset;">  <p>-0.33</p>  </td>  <td style="border-style: inset;">  <p>44.7</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[24/03/2021 14:00]</p>  </td>  <td style="border-style: inset;">  <p>-150.32</p>  </td>  <td style="border-style: inset;">  <p>44.7</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[24/03/2021 15:00]</p>  </td>  <td style="border-style: inset;">  <p>-3.9</p>  </td>  <td style="border-style: inset;">  <p>39.89</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[24/03/2021 16:00]</p>  </td>  <td style="border-style: inset;">  <p>12.01</p>  </td>  <td style="border-style: inset;">  <p>52.2</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[24/03/2021 17:00]</p>  </td>  <td style="border-style: inset;">  <p>34.31</p>  </td>  <td style="border-style: inset;">  <p>73.03</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[24/03/2021 18:00]</p>  </td>  <td style="border-style: inset;">  <p>-74.57</p>  </td>  <td style="border-style: inset;">  <p>54.21</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[24/03/2021 19:00]</p>  </td>  <td style="border-style: inset;">  <p>53.32</p>  </td>  <td style="border-style: inset;">  <p>64</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[24/03/2021 20:00]</p>  </td>  <td style="border-style: inset;">  <p>36.89</p>  </td>  <td style="border-style: inset;">  <p>423.58</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[24/03/2021 21:00]</p>  </td>  <td style="border-style: inset;">  <p>39.89</p>  </td>  <td style="border-style: inset;">  <p>54.14</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[24/03/2021 22:00]</p>  </td>  <td style="border-style: inset;">  <p>33.89</p>  </td>  <td style="border-style: inset;">  <p>53.97</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[24/03/2021 23:00]</p>  </td>  <td style="border-style: inset;">  <p>33</p>  </td>  <td style="border-style: inset;">  <p>53.73</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[25/03/2021 00:00]</p>  </td>  <td style="border-style: inset;">  <p>42.72</p>  </td>  <td style="border-style: inset;">  <p>45.84</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[25/03/2021 01:00]</p>  </td>  <td style="border-style: inset;">  <p>42.98</p>  </td>  <td style="border-style: inset;">  <p>46.58</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[25/03/2021 02:00]</p>  </td>  <td style="border-style: inset;">  <p>45.82</p>  </td>  <td style="border-style: inset;">  <p>48.1</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[25/03/2021 03:00]</p>  </td>  <td style="border-style: inset;">  <p>45.82</p>  </td>  <td style="border-style: inset;">  <p>51.27</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[25/03/2021 04:00]</p>  </td>  <td style="border-style: inset;">  <p>45.81</p>  </td>  <td style="border-style: inset;">  <p>49.51</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[25/03/2021 05:00]</p>  </td>  <td style="border-style: inset;">  <p>45.47</p>  </td>  <td style="border-style: inset;">  <p>53.81</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[25/03/2021 06:00]</p>  </td>  <td style="border-style: inset;">  <p>38.57</p>  </td>  <td style="border-style: inset;">  <p>53.42</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[25/03/2021 07:00]</p>  </td>  <td style="border-style: inset;">  <p>36.44</p>  </td>  <td style="border-style: inset;">  <p>54.34</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[25/03/2021 08:00]</p>  </td>  <td style="border-style: inset;">  <p>36.44</p>  </td>  <td style="border-style: inset;">  <p>40.51</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[25/03/2021 09:00]</p>  </td>  <td style="border-style: inset;">  <p>39.44</p>  </td>  <td style="border-style: inset;">  <p>61.15</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[25/03/2021 10:00]</p>  </td>  <td style="border-style: inset;">  <p>44.46</p>  </td>  <td style="border-style: inset;">  <p>87.73</p>  </td>  </tr>  <tr valign=top>  <td style="border-style: inset;">  <p>[25/03/2021 11:00]</p>  </td>  <td style="border-style: inset;">  <p>44.29</p>  </td>  <td style="border-style: inset;">  <p>45.02</p>  </td>  </tr>  </table>  </div>    </body></html>
https://stackoverflow.com/questions/66813103/how-to-identify-dates-where-a-certain-condition-is-met-in-python March 26, 2021 at 04:06PM

没有评论:

发表评论