<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rob Blatt</title>
	<atom:link href="http://www.robblatt.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.robblatt.com</link>
	<description>Data Scientist &#124; Data Analyst</description>
	<lastBuildDate>Tue, 27 Sep 2022 01:42:45 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>http://www.robblatt.com/wp-content/uploads/2017/10/cropped-12182515_10153877873684994_3452997619071958351_o-32x32.jpg</url>
	<title>Rob Blatt</title>
	<link>http://www.robblatt.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>DataFrame from Lists using Python and Pandas</title>
		<link>http://www.robblatt.com/code/dataframe-from-lists-using-python-and-pandas/</link>
		
		<dc:creator><![CDATA[Rob Blatt]]></dc:creator>
		<pubDate>Tue, 27 Sep 2022 01:42:45 +0000</pubDate>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[dataframe]]></category>
		<category><![CDATA[pandas]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">http://www.robblatt.com/?p=7423</guid>

					<description><![CDATA[>> import pandas as pd >> pd.DataFrame([['a', 'b', 'c'], ['as', 'easy', 'as'], [1, 2, 3]], columns = ['first', 'second', 'third']) >> import pandas as pd >> list1 = ['a', 'b', 'c'] >> list2 = ['as', 'easy', 'as'] >> list3 = [1, 2, 3] >> pd.DataFrame([list1, list2, list3], columns = ['first', 'second', 'third'])]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-preformatted"><code>>> import pandas as pd 
>> pd.DataFrame([['a', 'b', 'c'], ['as', 'easy', 'as'], [1, 2, 3]],</code> <code>columns = ['first', 'second', 'third'])</code>

<img fetchpriority="high" decoding="async" width="324" height="224" class="aligncenter size-full wp-image-7424" src="http://www.robblatt.com/wp-content/uploads/2022/09/Screen-Shot-2022-09-26-at-9.34.38-PM.png" alt="" srcset="http://www.robblatt.com/wp-content/uploads/2022/09/Screen-Shot-2022-09-26-at-9.34.38-PM.png 324w, http://www.robblatt.com/wp-content/uploads/2022/09/Screen-Shot-2022-09-26-at-9.34.38-PM-320x221.png 320w" sizes="(max-width: 324px) 100vw, 324px" />
<code>>> import pandas as pd 
>> list1 = ['a', 'b', 'c']
>> list2 = ['as', 'easy', 'as']
>> list3 = [1, 2, 3]
>> pd.DataFrame([list1, list2, list3], columns = ['first', 'second', 'third'])</code>
<img fetchpriority="high" decoding="async" width="324" height="224" class="aligncenter size-full wp-image-7424" src="http://www.robblatt.com/wp-content/uploads/2022/09/Screen-Shot-2022-09-26-at-9.34.38-PM.png" alt="" srcset="http://www.robblatt.com/wp-content/uploads/2022/09/Screen-Shot-2022-09-26-at-9.34.38-PM.png 324w, http://www.robblatt.com/wp-content/uploads/2022/09/Screen-Shot-2022-09-26-at-9.34.38-PM-320x221.png 320w" sizes="(max-width: 324px) 100vw, 324px" /></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Maple Syrup boils #1 and #2</title>
		<link>http://www.robblatt.com/hobbies/maple-syrup-boils-1-and-2/</link>
		
		<dc:creator><![CDATA[Rob Blatt]]></dc:creator>
		<pubDate>Wed, 09 Mar 2022 03:31:24 +0000</pubDate>
				<category><![CDATA[hobbies]]></category>
		<category><![CDATA[maple syrup]]></category>
		<guid isPermaLink="false">http://www.robblatt.com/?p=7409</guid>

					<description><![CDATA[&#8220;That&#8217;s a sugar maple, you could tap that if you wanted to.&#8221; The guy who was walking me through tree maintenance in the yard mentioned it offhand and I filed it away in the back of my mind. A few months later, after some reading about it, I bought a tree tapping kit off Amazon &#8230; <p class="link-more"><a href="http://www.robblatt.com/hobbies/maple-syrup-boils-1-and-2/" class="more-link">Continue reading<span class="screen-reader-text"> "Maple Syrup boils #1 and #2"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>&#8220;That&#8217;s a sugar maple, you could tap that if you wanted to.&#8221;</p>
<p>The guy who was walking me through tree maintenance in the yard mentioned it offhand and I filed it away in the back of my mind. A few months later, after some reading about it, I bought a <a href="https://amzn.to/35Ar4Sw">tree tapping kit off Amazon</a> that seemed easy enough to implement and kept a watch on the weather forecast to find the right day to tap the trees.</p>
<p>The kit had three taps and buckets, so I tapped three trees. Tree #1 is my superstar, producing the most sap and with the most sunlight during the day with the most space. Trees #2 and #3, who are known as the twins, are partially shaded and get less sun during the day. It was three days from the time I tapped it that all three buckets were pretty much full. Probably about seven gallons of sap.</p>
<p><img decoding="async" class="aligncenter size-large wp-image-7411" src="http://www.robblatt.com/wp-content/uploads/2022/03/53DA9DD7-0758-45D3-B0C1-C864CB7B6D4B-640x853.jpg" alt="Maple tree with a tap in it with a bucket attached that is mostly full." width="640" height="853" srcset="http://www.robblatt.com/wp-content/uploads/2022/03/53DA9DD7-0758-45D3-B0C1-C864CB7B6D4B-640x853.jpg 640w, http://www.robblatt.com/wp-content/uploads/2022/03/53DA9DD7-0758-45D3-B0C1-C864CB7B6D4B-320x427.jpg 320w, http://www.robblatt.com/wp-content/uploads/2022/03/53DA9DD7-0758-45D3-B0C1-C864CB7B6D4B-768x1024.jpg 768w, http://www.robblatt.com/wp-content/uploads/2022/03/53DA9DD7-0758-45D3-B0C1-C864CB7B6D4B-1152x1536.jpg 1152w, http://www.robblatt.com/wp-content/uploads/2022/03/53DA9DD7-0758-45D3-B0C1-C864CB7B6D4B-1536x2048.jpg 1536w, http://www.robblatt.com/wp-content/uploads/2022/03/53DA9DD7-0758-45D3-B0C1-C864CB7B6D4B-1568x2091.jpg 1568w, http://www.robblatt.com/wp-content/uploads/2022/03/53DA9DD7-0758-45D3-B0C1-C864CB7B6D4B-scaled.jpg 1920w" sizes="(max-width: 640px) 100vw, 640px" /></p>
<p>I grossly underestimated how long it would take to boil that amount of sap! I was very confident with Meg that it would take a few hours on a Sunday and we&#8217;d have plenty of time to relax with dinner before I sat down to watch the All Elite Wrestling pay-per-view Revolution. I started around 2 pm and it boiled. And boiled. And boiled. And boiled. I was using a turkey frying kit that I picked up at Home Depot, which has a pretty small surface area, meaning it would take longer to boil.</p>
<p><img decoding="async" class="aligncenter size-large wp-image-7412" src="http://www.robblatt.com/wp-content/uploads/2022/03/66830456346__9C3F04A6-4DF2-4FF2-A3FB-3B5669A6E24B-640x480.jpeg" alt="Photo of wrestling on a projector while sap boils in a container on a deck outdoors." width="640" height="480" srcset="http://www.robblatt.com/wp-content/uploads/2022/03/66830456346__9C3F04A6-4DF2-4FF2-A3FB-3B5669A6E24B-640x480.jpeg 640w, http://www.robblatt.com/wp-content/uploads/2022/03/66830456346__9C3F04A6-4DF2-4FF2-A3FB-3B5669A6E24B-320x240.jpeg 320w, http://www.robblatt.com/wp-content/uploads/2022/03/66830456346__9C3F04A6-4DF2-4FF2-A3FB-3B5669A6E24B-768x576.jpeg 768w, http://www.robblatt.com/wp-content/uploads/2022/03/66830456346__9C3F04A6-4DF2-4FF2-A3FB-3B5669A6E24B.jpeg 1280w" sizes="(max-width: 640px) 100vw, 640px" /></p>
<p>Thankfully, it was a warm night and I was able to hang out outside, enjoy the night, the pay-per-view, and keep resetting the turkey fryer&#8217;s automatic safety timer every fifteen minutes. I think the boil was mostly done around 11 pm. I jarred what was left and would handle it in the morning.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-7413" src="http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1353-640x853.jpeg" alt="A jar of sap and a 33 quart container how it started" width="640" height="853" srcset="http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1353-640x853.jpeg 640w, http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1353-320x427.jpeg 320w, http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1353-768x1024.jpeg 768w, http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1353.jpeg 960w" sizes="auto, (max-width: 640px) 100vw, 640px" /></p>
<p>In the morning I boiled down the rest from about 4 cups to about 2 cups. It filled the house with a great smell that soon became overwhelming and required all the windows to be opened. About an hour later, I had syrup!</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-7415" src="http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1357-640x853.jpeg" alt="A jar of syrup" width="640" height="853" srcset="http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1357-640x853.jpeg 640w, http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1357-320x427.jpeg 320w, http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1357-768x1024.jpeg 768w, http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1357.jpeg 960w" sizes="auto, (max-width: 640px) 100vw, 640px" /></p>
<p>Ultimately, it&#8217;s syrup! It&#8217;s amazing that I can just make this stuff myself! I haven&#8217;t used it yet but I spent the day walking to the fridge and dipping a finger in for a taste of it. I named it after Adam Page, the current AEW heavyweight champion, since I watched him retain his championship while it was finishing the larger boil.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-7416" src="http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1366-640x853.jpeg" alt="My maple sap boiling on my deck" width="640" height="853" srcset="http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1366-640x853.jpeg 640w, http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1366-320x427.jpeg 320w, http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1366-768x1024.jpeg 768w, http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1366.jpeg 960w" sizes="auto, (max-width: 640px) 100vw, 640px" /></p>
<p>I started the second boil the next day (Tuesday) but after a disaster. It was especially windy and Tree #1&#8217;s bucket was nearly full and the weight combined with the wind pulled it right off the tree. The twins produced enough to get a small batch going. I still had daylight, so I worked for about two hours outside while the boil got to a good enough place to bring it inside to finish up. A bit too chilly to really enjoy the day but I brought it inside before dinner.</p>
<p>I filtered the sap multiple times, probably once more than was needed but I wanted to see if I could produce something more clear than the first batch. In honor of my sap disaster, I named the second batch Dr. Bunsen Honeydew.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-large wp-image-7417" src="http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1368-640x853.jpeg" alt="A jar of sap, labeled Boil #2 Dr Bunsen Honeydew 3/8/22" width="640" height="853" srcset="http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1368-640x853.jpeg 640w, http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1368-320x427.jpeg 320w, http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1368-768x1024.jpeg 768w, http://www.robblatt.com/wp-content/uploads/2022/03/IMG_1368.jpeg 960w" sizes="auto, (max-width: 640px) 100vw, 640px" /></p>
<p>I still have some work to do and there are some tools that can help me get this done a bit easier than it has been, but it&#8217;s still been fun. The amount left on the second boil and the lighter color makes me think that I probably didn&#8217;t boil it enough but the taste seemed about right. To really test it, I&#8217;d need a <a href="https://amzn.to/3IVy8aL">refractometer</a> to see the sugar content. Not sure if this batch needs another filter or not but I&#8217;m happy with this round too. I&#8217;ll need some smaller jars too if I&#8217;ll keep doing this every few days.</p>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Yelp Ratings Exploration</title>
		<link>http://www.robblatt.com/yelp/yelp-ratings-exploration/</link>
		
		<dc:creator><![CDATA[Rob Blatt]]></dc:creator>
		<pubDate>Sun, 12 Jul 2020 19:13:53 +0000</pubDate>
				<category><![CDATA[Yelp]]></category>
		<category><![CDATA[Ratings]]></category>
		<category><![CDATA[yelp]]></category>
		<guid isPermaLink="false">http://www.robblatt.com/?p=7396</guid>

					<description><![CDATA[I&#8217;ve had an obsession with Yelp ratings since I started my data science capstone project at Flatiron School. Yelp ratings can be useful, but as a restaurant/bar gets older, the ratings become more useless. An example would be the Yelp score for Lombardi&#8217;s, which claims to be NYC&#8217;s oldest pizza joint. The black line shows &#8230; <p class="link-more"><a href="http://www.robblatt.com/yelp/yelp-ratings-exploration/" class="more-link">Continue reading<span class="screen-reader-text"> "Yelp Ratings Exploration"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve had an obsession with Yelp ratings since I <a href="https://github.com/robblatt/PIZZAmetrics">started my data science capstone project</a> at Flatiron School. Yelp ratings can be useful, but as a restaurant/bar gets older, the ratings become more useless. An example would be the Yelp score for Lombardi&#8217;s, which claims to be NYC&#8217;s oldest pizza joint.</p>
<p><figure style="width: 720px" class="wp-caption aligncenter"><a href="http://www.robblatt.com/wp-content/uploads/2020/07/1dqedd8QxdMQa_s_O395lvg.png"><img loading="lazy" decoding="async" class="size-medium" src="http://www.robblatt.com/wp-content/uploads/2020/07/1dqedd8QxdMQa_s_O395lvg.png" alt="Lombardi's Yelp score over time." width="720" height="387" /></a><figcaption class="wp-caption-text">Lombardi&#8217;s Yelp score over time and a 250 review rolling average. Click the image to read more about how I created this graph.</figcaption></figure></p>
<p>The black line shows Lombardi&#8217;s Yelp score over time, the green horizontal line shows the average score as of September 2019. In September of 2006, Lombardi&#8217;s hit 4 stars and hasn&#8217;t changed since. You can see from the black line that the average has been slowly trending towards 3.5 stars, but the rating was 0.0385 stars above the threshold. The rolling mean tells a more complete story, having drifted into the 3.5 star territory in 2015.</p>
<p>How many of those 6,000 reviews are quality reviews?</p>
<p>In order to see the impact of filtering reviewers, I took a look at the Yelp reviews of <a href="https://www.yelp.com/biz/young-ethels-brooklyn">Young Ethel&#8217;s</a>, a bar that I love in Brooklyn, that has 19 reviews and 5 stars. 15 five star reviews, 4 four star reviews, a <strong>4.7895 star score</strong>.</p>
<p>Since Young Ethel&#8217;s is relatively new, we can assume that their friends and family will write some reviews to help them get started.</p>
<p><figure id="attachment_7398" aria-describedby="caption-attachment-7398" style="width: 1502px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-7398 size-full" src="http://www.robblatt.com/wp-content/uploads/2020/07/Screen-Shot-2020-07-12-at-2.13.26-PM.png" alt="" width="1502" height="412" srcset="http://www.robblatt.com/wp-content/uploads/2020/07/Screen-Shot-2020-07-12-at-2.13.26-PM.png 1502w, http://www.robblatt.com/wp-content/uploads/2020/07/Screen-Shot-2020-07-12-at-2.13.26-PM-320x88.png 320w, http://www.robblatt.com/wp-content/uploads/2020/07/Screen-Shot-2020-07-12-at-2.13.26-PM-640x176.png 640w, http://www.robblatt.com/wp-content/uploads/2020/07/Screen-Shot-2020-07-12-at-2.13.26-PM-768x211.png 768w" sizes="auto, (max-width: 1502px) 100vw, 1502px" /><figcaption id="caption-attachment-7398" class="wp-caption-text">A questionable review</figcaption></figure></p>
<p>A few red flags for this review. No friends, no user photo, a low number of reviews. I know the opening date of the bar (August 22, 2019), so this is also within a month of opening.</p>
<p>Of the 19 reviewers, 3 are missing user photos and 3 have no friends. 5 have neither.</p>
<p>All reviews: <strong>4.7895 stars</strong></p>
<p>Reviewers with Photos: <strong>4.75 stars</strong> (-0.0395 difference)</p>
<p>Reviewers with Friends: <strong>4.75 stars</strong> (-0.0395 difference)</p>
<p>Reviewers with Photos and Friends: <strong>4.7143 stars</strong> (-0.0752 difference)</p>
<p><figure id="attachment_7401" aria-describedby="caption-attachment-7401" style="width: 420px" class="wp-caption alignright"><img loading="lazy" decoding="async" class="wp-image-7401 size-full" src="http://www.robblatt.com/wp-content/uploads/2020/07/Screen-Shot-2020-07-12-at-2.59.43-PM.png" alt="" width="420" height="276" srcset="http://www.robblatt.com/wp-content/uploads/2020/07/Screen-Shot-2020-07-12-at-2.59.43-PM.png 420w, http://www.robblatt.com/wp-content/uploads/2020/07/Screen-Shot-2020-07-12-at-2.59.43-PM-320x210.png 320w" sizes="auto, (max-width: 420px) 100vw, 420px" /><figcaption id="caption-attachment-7401" class="wp-caption-text">An overview of an Elite reviewer&#8217;s profile. Are all 3,800 reviews honest?</figcaption></figure></p>
<p>Filtering out the reviewers that have no photos or friends, we&#8217;ve lowered the star rating by half a star. There&#8217;s one more group I believe that should be filtered out, which are <a href="https://www.yelp.com/elite">Yelp Elite Squad members</a>. Elite members are rewarded for interactive on the site with exclusive events. New businesses would be prime for new reviews from Elite members. Since I&#8217;m looking to filter out reviews that aren&#8217;t genuine, I&#8217;d be remiss in leaving Elite reviews in the score.</p>
<p>Non-Elite Reviewers with Photos and Friends: <strong>4.8 stars</strong> (0.0105 difference)</p>
<p>By removing Elite reviews, the score is up in comparison to the score. Without the Elite members and suspect reviewers, there are 10 reviews left.</p>
<p>My next step would be to see what impact this has on a larger scale, but for now, it&#8217;s interesting to see how weeding out reviews can impact the overall score.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Speeding Up Creating Multiple Empty Lists in Python</title>
		<link>http://www.robblatt.com/code/speeding-up-creating-multiple-empty-lists-in-python/</link>
		
		<dc:creator><![CDATA[Rob Blatt]]></dc:creator>
		<pubDate>Sat, 27 Jun 2020 19:07:47 +0000</pubDate>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[lists]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">http://www.robblatt.com/?p=7389</guid>

					<description><![CDATA[list_len = len(old_list) list = [None] * list_len not list = [None] * len(old_list) Use Case: When I create DataFrames, I&#8217;ll create a series of lists to fill. The DataFrame is created by using lists. reviews is a list of HTML blocks. Here&#8217;s how I would have normally set up the lists. texts = [None] &#8230; <p class="link-more"><a href="http://www.robblatt.com/code/speeding-up-creating-multiple-empty-lists-in-python/" class="more-link">Continue reading<span class="screen-reader-text"> "Speeding Up Creating Multiple Empty Lists in Python"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p><code>list_len = len(old_list)<br />
list = [None] * list_len</code></p>
<p>not</p>
<p><code>list = [None] * len(old_list)<br />
</code></p>
<p><strong>Use Case:</strong></p>
<p>When I create DataFrames, I&#8217;ll create a series of lists to fill. The DataFrame is created by using lists. <code>reviews</code> is a list of HTML blocks. Here&#8217;s how I would have normally set up the lists.</p>
<p><code>texts = [None] * len(reviews)<br />
dates = [None] * len(reviews)<br />
ratings = [None] * len(reviews)<br />
checkin = [None] * len(reviews)<br />
photos = [None] * len(reviews)</code></p>
<p>A quick timing shows that <code>texts = [None] * len(reviews)</code> is about 22% slower than using a defined variable as the length of the list.</p>
<p>Time to create five empty lists with a length of 20:</p>
<ul>
<li>Using review_len: 772 ns ± 5.66 ns</li>
<li>Using len(reviews): 969 ns ± 13.5 ns</li>
<li>Using 20: 706 ns ± 14 ns</li>
</ul>
<p>I&#8217;m surprised to see that using a definitive length, 20, didn&#8217;t save more time.</p>
<p>Saving nanoseconds may seem like a trivial amount of time, but continually attempting to optimize code is admirable.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Round Numbers and Days Up in Python</title>
		<link>http://www.robblatt.com/code/round-numbers-up-in-python/</link>
		
		<dc:creator><![CDATA[Rob Blatt]]></dc:creator>
		<pubDate>Fri, 21 Feb 2020 15:07:33 +0000</pubDate>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">http://www.robblatt.com/?p=6618</guid>

					<description><![CDATA[&#62;&#62; import math &#62;&#62; math.ceil(1.1) 2 Timedelta('21 days 15:00:00') &#62;&#62; pd.Timedelta.ceil(df.delta.mean(), freq = 'd') Timedelta('22 days 00:00:00') Use Case: I have a DataFrame with two sets of dates and the difference between them. There are two different ways to get a rounded up number of days, depending if you want a Timedelta or an integer. &#8230; <p class="link-more"><a href="http://www.robblatt.com/code/round-numbers-up-in-python/" class="more-link">Continue reading<span class="screen-reader-text"> "Round Numbers and Days Up in Python"</span></a></p>]]></description>
										<content:encoded><![CDATA[<pre>&gt;&gt; import math
&gt;&gt; math.ceil(1.1)
2

Timedelta('21 days 15:00:00')

&gt;&gt; pd.Timedelta.ceil(df.delta.mean(), freq = 'd')
Timedelta('22 days 00:00:00')</pre>
<p><strong>Use Case:</strong></p>
<p>I have a DataFrame with two sets of dates and the difference between them. There are two different ways to get a rounded up number of days, depending if you want a Timedelta or an integer.</p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-6616 aligncenter" src="http://www.robblatt.com/wp-content/uploads/2020/02/Screen-Shot-2020-02-20-at-4.43.40-PM.png" alt="DataFrame of two sets of dates and the difference between them" width="244" height="245" srcset="http://www.robblatt.com/wp-content/uploads/2020/02/Screen-Shot-2020-02-20-at-4.43.40-PM.png 244w, http://www.robblatt.com/wp-content/uploads/2020/02/Screen-Shot-2020-02-20-at-4.43.40-PM-160x160.png 160w" sizes="auto, (max-width: 244px) 100vw, 244px" /></p>
<p><strong>Method 1: Integer</strong></p>
<pre>&gt;&gt; df.delta.mean()
Timedelta('21 days 15:00:00')
&gt;&gt; df_ex.delta.mean() / pd.Timedelta(days = 1)
21.625</pre>
<p>That&#8217;s the answer, but also for my purposes, partial days is too fine for my purposes. Dividing a Timedelta by pd.Timedelta(days = 1) will result in an integer.</p>
<pre>&gt;&gt; math.ceil(df_ex.delta.mean() / pd.Timedelta(days = 1))
22</pre>
<p><strong>Method 2: Timedelta</strong></p>
<pre>&gt;&gt; df.delta.mean()
Timedelta('21 days 15:00:00')

&gt;&gt; pd.Timedelta.ceil(df.delta.mean(), freq = 'd')
Timedelta('22 days 00:00:00')</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
