<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mattalhonte</title>
    <description>The latest articles on DEV Community by mattalhonte (@mattalhonte).</description>
    <link>https://dev.to/mattalhonte</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F34373%2F6671fd83-7478-489a-8f21-8fd01122b15f.png</url>
      <title>DEV Community: mattalhonte</title>
      <link>https://dev.to/mattalhonte</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mattalhonte"/>
    <language>en</language>
    <item>
      <title>Downcast Numerical Data Types with Pandas</title>
      <dc:creator>mattalhonte</dc:creator>
      <pubDate>Mon, 28 Jan 2019 12:30:00 +0000</pubDate>
      <link>https://dev.to/hackersandslackers/downcast-numerical-data-types-with-pandas-d19</link>
      <guid>https://dev.to/hackersandslackers/downcast-numerical-data-types-with-pandas-d19</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NctWN-Br--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res-5.cloudinary.com/hackers-and-slackers/image/upload/f_auto%2Cq_auto/v1/images/codesnippetdatatypes%25402x.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NctWN-Br--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res-5.cloudinary.com/hackers-and-slackers/image/upload/f_auto%2Cq_auto/v1/images/codesnippetdatatypes%25402x.jpg" alt="Downcast Numerical Data Types with Pandas"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Recently, I had to find a way to reduce the memory footprint of a Pandas DataFrame in order to actually do operations on it.  Here's a trick that came in handy!&lt;/p&gt;

&lt;p&gt;By default, if you read a DataFrame from a file, it'll cast all the numerical columns as the &lt;code&gt;float64&lt;/code&gt; type.  This is in keeping with the philosophy behind Pandas and NumPy - by using strict types (instead of normal Python "duck typing"), you can do things a lot faster.  The &lt;code&gt;float64&lt;/code&gt; is the most flexible numerical type - it can handle fractions, as well as turning missing values into a &lt;code&gt;NaN&lt;/code&gt;.  This will let us read it into memory, and then start messing with it.  The downside is that it consumes a lot of memory.&lt;/p&gt;

&lt;p&gt;Now, let's say we want to save memory by manually downcasting our columns into the smallest type that can handle its values?  And let's ALSO say that we want to be really, really lazy and don't want to look at a bunch of numbers by hand.  And let's say we wanna do this via Method Chaining, because of all the advantages outlined here: &lt;a href="https://tomaugspurger.github.io/method-chaining"&gt;https://tomaugspurger.github.io/method-chaining&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's introduce our example DataFrame.  We'll convert all the values to floats manually because that's what the default is when we read from a file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df = pd.DataFrame({
    "stay_float": [0.5, 3.7, 7.5],
    "to_int": [-5, 7, 5],
    "to_uint": [1, 100, 200]}).astype(float)

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;First, let's introduce the workhorse of this exercise - Pandas's &lt;code&gt;to_numeric&lt;/code&gt; function, and its handy optional argument, &lt;code&gt;downcast&lt;/code&gt;.  This will take a numerical type - &lt;code&gt;float&lt;/code&gt;, &lt;code&gt;integer&lt;/code&gt; (not &lt;code&gt;int&lt;/code&gt;), or &lt;code&gt;unsigned&lt;/code&gt; - and then downcast it to the smallest version available.&lt;/p&gt;

&lt;p&gt;Next, let's make a function that checks to see if a column can be downcast from a float to an integer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def float_to_int(ser):
    try:
        int_ser = ser.astype(int)
        if (ser == int_ser).all():
            return int_ser
        else:
            return ser
    except ValueError:
        return ser
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We're using the try/except pattern here because if we try to make a column with &lt;code&gt;NaN&lt;/code&gt; values into an integer column, it'll throw an error.  If it'd otherwise be a good candidate for turning into an integer, we should figure a value to impute for those missing values - but that'll be different for every column.  Sometimes it'd make sense to make it 0, other times the mean or median of the column, or something else entirely.&lt;/p&gt;

&lt;p&gt;I'd also like to direct your attention to Line 4, which has a very useful Pandas pattern - &lt;code&gt;if (ser == int_ser).all()&lt;/code&gt;.  When you do operations on Pandas columns like Equals or Greater Than, you get a new column where the operation was applied element-by-element.  If you're trying to set up a conditional, the interpreter doesn't know what to do with an array containing &lt;code&gt;[True, False, True]&lt;/code&gt; - you have to boil it down to a single value.  So, if you wan to check if two columns are completely equal, you have to call the &lt;code&gt;.all()&lt;/code&gt; method (which has a useful sibling, &lt;code&gt;any()&lt;/code&gt;) to make a conditional that can actually be used to control execution.&lt;/p&gt;

&lt;p&gt;Next, let's make a function that lets us apply a transformation to multiple columns based on a condition.  The &lt;code&gt;assign&lt;/code&gt; method is pretty awesome, and it'd be fun to not have to leave it (or, if we do, to at least replace it with a function we can pipe as part of a chain of transformations to the DataFrame as a whole).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def multi_assign(df, transform_fn, condition):
    df_to_use = df.copy()

    return (df_to_use
        .assign(
            **{col: transform_fn(df_to_use[col])
               for col in condition(df_to_use)})
           )

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;assign&lt;/code&gt; lets us do multiple assignments, so long as we make a dictionary of column names and target values and then unpack it.  Really, it'd actually be easier to skip the function and go directly to using this syntax, except that I'm not aware of a method of accessing a filterable list of the DF's columns while still "in" the chain.  I think future versions of Pandas' syntax will include this, as I've read they want to support more Method Chaining.  Personally, I find the reduction in Cognitive Load is worth it, with having a lot of little modular lego-piece transformations chained together.  &lt;/p&gt;

&lt;p&gt;It also works as a nice foundation for other little helper functions.  So, here's one to turn as many float columns to integers as we can.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def all_float_to_int(df):
    df_to_use = df.copy()
    transform_fn = float_to_int
    condition = lambda x: list(x
                    .select_dtypes(include=["float"])
                    .columns)    

    return multi_assign(df_to_use, transform_fn, condition)

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;See the pattern in action!  We decide on a transformation function, we decide on what conditions we want to apply all these transformations (we could have a hundred columns, and who wants to make a note of all that?), and then we pass it to the &lt;code&gt;multi-assign&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(df
     .pipe(all_float_to_int)).dtypes


stay_float float64
to_int int64
to_uint int64
dtype: object

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Cool!  But we didn't actually decrease the size of our DataFrame - 64 bytes of integer takes up as many bytes as 64 bytes of float, just like how a hundred pounds of feathers weighs as much as a hundred pounds of bricks.  What we did do is make it easier to downcast those columns later.&lt;/p&gt;

&lt;p&gt;Next, let's make a function that takes a subset of the columns, and tries to downcast it to the smallest version that it can.  We've got fairly small values here, so it should get some work done.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def downcast_all(df, target_type, inital_type=None):
    #Gotta specify floats, unsigned, or integer
    #If integer, gotta be 'integer', not 'int'
    #Unsigned should look for Ints
    if inital_type is None:
        inital_type = target_type

    df_to_use = df.copy()

    transform_fn = lambda x: pd.to_numeric(x, 
                                downcast=target_type)

    condition = lambda x: list(x
                    .select_dtypes(include=[inital_type])
                    .columns) 

    return multi_assign(df_to_use, transform_fn, condition)

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Same basic pattern as before!  But now we have two arguments - one is the &lt;code&gt;target_type&lt;/code&gt;, which tells us what types to try to downcast to.  By default, this will be the same as the &lt;code&gt;initial_type&lt;/code&gt;, with one exception that we'll grab in a second!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(df
     .pipe(all_float_to_int)
     .pipe(downcast_all, "float")
     .pipe(downcast_all, "integer")
).dtypes


stay_float float32
to_int int8
to_uint int16
dtype: object

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Alright, now we're getting somewhere!  Wonder if we can do even better, though?  That last column has a conspicuous name!  And it has no values lower than 0 - maybe we could save space if we store it as an unsigned integer!  Let's add a pipe to our chain that'll try to downcast certain integers into unsigneds...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(df
     .pipe(all_float_to_int)
     .pipe(downcast_all, "float")
     .pipe(downcast_all, "integer")
     .pipe(downcast_all,  
           target_type = "unsigned", 
           inital_type = "integer")
).dtypes


stay_float float32
to_int int8
to_uint uint8
dtype: objec

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;What do ya know, we can!&lt;/p&gt;

&lt;p&gt;Let's see how much memory we save by doing this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df.info(memory_usage='deep')


&amp;lt;class 'pandas.core.frame.DataFrame'&amp;gt;
RangeIndex: 3 entries, 0 to 2
Data columns (total 3 columns):
stay_float 3 non-null float64
to_int 3 non-null float64
to_uint 3 non-null float64
dtypes: float64(3)
memory usage: 152.0 bytes

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;vs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(df
     .pipe(all_float_to_int)
     .pipe(downcast_all, "float")
     .pipe(downcast_all, "integer")
     .pipe(downcast_all,  
           target_type = "unsigned", 
           inital_type = "integer")
).info(memory_usage='deep')


&amp;lt;class 'pandas.core.frame.DataFrame'&amp;gt;
RangeIndex: 3 entries, 0 to 2
Data columns (total 3 columns):
stay_float 3 non-null float32
to_int 3 non-null int8
to_uint 3 non-null uint8
dtypes: float32(1), int8(1), uint8(1)
memory usage: 98.0 bytes

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;152 down to 98 - we reduced it by more than 1/3rd!&lt;/p&gt;

</description>
      <category>pandas</category>
      <category>python</category>
    </item>
    <item>
      <title>Code Snippet Corner: Using Pandas' Assign Function on Multiple Columns</title>
      <dc:creator>mattalhonte</dc:creator>
      <pubDate>Mon, 28 Jan 2019 12:30:00 +0000</pubDate>
      <link>https://dev.to/hackersandslackers/code-snippet-corner-using-pandas-assign-function-on-multiple-columns-3pj7</link>
      <guid>https://dev.to/hackersandslackers/code-snippet-corner-using-pandas-assign-function-on-multiple-columns-3pj7</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NctWN-Br--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res-5.cloudinary.com/hackers-and-slackers/image/upload/f_auto%2Cq_auto/v1/images/codesnippetdatatypes%25402x.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NctWN-Br--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res-5.cloudinary.com/hackers-and-slackers/image/upload/f_auto%2Cq_auto/v1/images/codesnippetdatatypes%25402x.jpg" alt="Code Snippet Corner: Using Pandas' Assign Function on Multiple Columns"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Recently, I had to find a way to reduce the memory footprint of a Pandas DataFrame in order to actually do operations on it.  Here's a trick that came in handy!&lt;/p&gt;

&lt;p&gt;By default, if you read a DataFrame from a file, it'll cast all the numerical columns as the &lt;code&gt;float64&lt;/code&gt; type.  This is in keeping with the philosophy behind Pandas and NumPy - by using strict types (instead of normal Python "duck typing"), you can do things a lot faster.  The &lt;code&gt;float64&lt;/code&gt; is the most flexible numerical type - it can handle fractions, as well as turning missing values into a &lt;code&gt;NaN&lt;/code&gt;.  This will let us read it into memory, and then start messing with it.  The downside is that it consumes a lot of memory.&lt;/p&gt;

&lt;p&gt;Now, let's say we want to save memory by manually downcasting our columns into the smallest type that can handle its values?  And let's ALSO say that we want to be really, really lazy and don't want to look at a bunch of numbers by hand.  And let's say we wanna do this via Method Chaining, because of all the advantages outlined here: &lt;a href="https://tomaugspurger.github.io/method-chaining"&gt;https://tomaugspurger.github.io/method-chaining&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's introduce our example DataFrame.  We'll convert all the values to floats manually because that's what the default is when we read from a file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df = pd.DataFrame({
    "stay_float": [0.5, 3.7, 7.5],
    "to_int": [-5, 7, 5],
    "to_uint": [1, 100, 200]}).astype(float)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;First, let's introduce the workhorse of this exercise - Pandas's &lt;code&gt;to_numeric&lt;/code&gt; function, and its handy optional argument, &lt;code&gt;downcast&lt;/code&gt;.  This will take a numerical type - &lt;code&gt;float&lt;/code&gt;, &lt;code&gt;integer&lt;/code&gt; (not &lt;code&gt;int&lt;/code&gt;), or &lt;code&gt;unsigned&lt;/code&gt; - and then downcast it to the smallest version available.&lt;/p&gt;

&lt;p&gt;Next, let's make a function that checks to see if a column can be downcast from a float to an integer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def float_to_int(ser):
    try:
        int_ser = ser.astype(int)
        if (ser == int_ser).all():
            return int_ser
        else:
            return ser
    except ValueError:
        return ser
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We're using the try/except pattern here because if we try to make a column with &lt;code&gt;NaN&lt;/code&gt; values into an integer column, it'll throw an error.  If it'd otherwise be a good candidate for turning into an integer, we should figure a value to impute for those missing values - but that'll be different for every column.  Sometimes it'd make sense to make it 0, other times the mean or median of the column, or something else entirely.&lt;/p&gt;

&lt;p&gt;I'd also like to direct your attention to Line 4, which has a very useful Pandas pattern - &lt;code&gt;if (ser == int_ser).all()&lt;/code&gt;.  When you do operations on Pandas columns like Equals or Greater Than, you get a new column where the operation was applied element-by-element.  If you're trying to set up a conditional, the interpreter doesn't know what to do with an array containing &lt;code&gt;[True, False, True]&lt;/code&gt; - you have to boil it down to a single value.  So, if you wan to check if two columns are completely equal, you have to call the &lt;code&gt;.all()&lt;/code&gt; method (which has a useful sibling, &lt;code&gt;any()&lt;/code&gt;) to make a conditional that can actually be used to control execution.&lt;/p&gt;

&lt;p&gt;Next, let's make a function that lets us apply a transformation to multiple columns based on a condition.  The &lt;code&gt;assign&lt;/code&gt; method is pretty awesome, and it'd be fun to not have to leave it (or, if we do, to at least replace it with a function we can pipe as part of a chain of transformations to the DataFrame as a whole).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def multi_assign(df, transform_fn, condition):
    df_to_use = df.copy()

    return (df_to_use
        .assign(
            **{col: transform_fn(df_to_use[col])
               for col in condition(df_to_use)})
           )
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;assign&lt;/code&gt; lets us do multiple assignments, so long as we make a dictionary of column names and target values and then unpack it.  Really, it'd actually be easier to skip the function and go directly to using this syntax, except that I'm not aware of a method of accessing a filterable list of the DF's columns while still "in" the chain.  I think future versions of Pandas' syntax will include this, as I've read they want to support more Method Chaining.  Personally, I find the reduction in Cognitive Load is worth it, with having a lot of little modular lego-piece transformations chained together.  &lt;/p&gt;

&lt;p&gt;It also works as a nice foundation for other little helper functions.  So, here's one to turn as many float columns to integers as we can.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def all_float_to_int(df):
    df_to_use = df.copy()
    transform_fn = float_to_int
    condition = lambda x: list(x
                    .select_dtypes(include=["float"])
                    .columns)    

    return multi_assign(df_to_use, transform_fn, condition)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;See the pattern in action!  We decide on a transformation function, we decide on what conditions we want to apply all these transformations (we could have a hundred columns, and who wants to make a note of all that?), and then we pass it to the &lt;code&gt;multi-assign&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(df
     .pipe(all_float_to_int)).dtypes

stay_float float64
to_int int64
to_uint int64
dtype: object
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Cool!  But we didn't actually decrease the size of our DataFrame - 64 bytes of integer takes up as many bytes as 64 bytes of float, just like how a hundred pounds of feathers weighs as much as a hundred pounds of bricks.  What we did do is make it easier to downcast those columns later.&lt;/p&gt;

&lt;p&gt;Next, let's make a function that takes a subset of the columns, and tries to downcast it to the smallest version that it can.  We've got fairly small values here, so it should get some work done.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def downcast_all(df, target_type, inital_type=None):
    #Gotta specify floats, unsigned, or integer
    #If integer, gotta be 'integer', not 'int'
    #Unsigned should look for Ints
    if inital_type is None:
        inital_type = target_type

    df_to_use = df.copy()

    transform_fn = lambda x: pd.to_numeric(x, 
                                downcast=target_type)

    condition = lambda x: list(x
                    .select_dtypes(include=[inital_type])
                    .columns) 

    return multi_assign(df_to_use, transform_fn, condition)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Same basic pattern as before!  But now we have two arguments - one is the &lt;code&gt;target_type&lt;/code&gt;, which tells us what types to try to downcast to.  By default, this will be the same as the &lt;code&gt;initial_type&lt;/code&gt;, with one exception that we'll grab in a second!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(df
     .pipe(all_float_to_int)
     .pipe(downcast_all, "float")
     .pipe(downcast_all, "integer")
).dtypes

stay_float float32
to_int int8
to_uint int16
dtype: object
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Alright, now we're getting somewhere!  Wonder if we can do even better, though?  That last column has a conspicuous name!  And it has no values lower than 0 - maybe we could save space if we store it as an unsigned integer!  Let's add a pipe to our chain that'll try to downcast certain integers into unsigneds...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(df
     .pipe(all_float_to_int)
     .pipe(downcast_all, "float")
     .pipe(downcast_all, "integer")
     .pipe(downcast_all,  
           target_type = "unsigned", 
           inital_type = "integer")
).dtypes

stay_float float32
to_int int8
to_uint uint8
dtype: objec
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;What do ya know, we can!&lt;/p&gt;

&lt;p&gt;Let's see how much memory we save by doing this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df.info(memory_usage='deep')

&amp;lt;class 'pandas.core.frame.DataFrame'&amp;gt;
RangeIndex: 3 entries, 0 to 2
Data columns (total 3 columns):
stay_float 3 non-null float64
to_int 3 non-null float64
to_uint 3 non-null float64
dtypes: float64(3)
memory usage: 152.0 bytes
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;vs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(df
     .pipe(all_float_to_int)
     .pipe(downcast_all, "float")
     .pipe(downcast_all, "integer")
     .pipe(downcast_all,  
           target_type = "unsigned", 
           inital_type = "integer")
).info(memory_usage='deep')

&amp;lt;class 'pandas.core.frame.DataFrame'&amp;gt;
RangeIndex: 3 entries, 0 to 2
Data columns (total 3 columns):
stay_float 3 non-null float32
to_int 3 non-null int8
to_uint 3 non-null uint8
dtypes: float32(1), int8(1), uint8(1)
memory usage: 98.0 bytes
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;152 down to 98 - we reduced it by more than 1/3rd!&lt;/p&gt;

</description>
      <category>pandas</category>
      <category>python</category>
    </item>
  </channel>
</rss>
