Sunday, June 4, 2017

Sunday: The last day off for two weeks.

So, of course, I spent a chunk of the evening queuing data to download at work, and launching some processing jobs.  This doesn't work well with my plan to "don't do work stuff as much as possible."

I discovered today that because I've been walking, I've apparently lost weight.  That means I now have pants that do not fit because they're too big.  Whoops.  I can't wait until we get to the world completely run by millennials, because at that point, everyone will stop being dumb and we'll all just wear whatever's comfortable, because who wants to wear shit that isn't soft and stretchy?

Today's actual main plan was to go to Target.  Sunday is always a bad day to go to Target, because everyone is there.

Then sushi, because I honestly couldn't decide what I wanted, and unagi kind of sounded good.
It was super good.  Today also marks the end of my reign of terror at Dole plantation:
What?

Someone finally killed Cloyster.
Either that or there's some check in place to make sure you don't hold a gym for longer than two weeks.  That'd be fine with me.  I did briefly think about driving out to take it back, but ended up feeling like sitting on the couch being lazy was a better option.

Final interesting thing:  Julie asked a question about truncating values in a vector that I couldn't answer because I don't know pandas.  "How would I do that in R?" I thought.  So I came up with a solution.  Then a better solution.  Then a better solution.  Then a solution that is basically the same, just slightly lazier.

# Read example data
df = data.frame(read.csv("/tmp/x.csv",header=TRUE))
df
  title values otherstuff
1     A      1        0.6
2     B      2        0.5
3     C     33        0.4
4     D      4        0.3
5     E      5        0.2
6     F     79        0.1

# Use which in index mode to find values above some threshold and assign a new value. Replace accepts the list of indices that match the query, and replaces the values they point to.
df$values2 = replace(df$values,which(df$values > 5, arr.ind = TRUE), 5) ; df
  title values otherstuff values2
1     A      1        0.6       1
2     B      2        0.5       2
3     C     33        0.4       5
4     D      4        0.3       4
5     E      5        0.2       5
6     F     79        0.1       5

# Define a logical selection above the threshold.  Replace accepts a list of Booleans to indicate which values to replace.
L = df$values > 5
df$values3 = replace(df$values,L,5); df
  title values otherstuff values2 values3
1     A      1        0.6       1       1
2     B      2        0.5       2       2
3     C     33        0.4       5       5
4     D      4        0.3       4       4
5     E      5        0.2       5       5
6     F     79        0.1       5       5

# Do that all at once, avoiding using an intermediate vector.
df$values4 = replace(df$values,df$values > 5,5); df
  title values otherstuff values2 values3 values4
1     A      1        0.6       1       1       1
2     B      2        0.5       2       2       2
3     C     33        0.4       5       5       5
4     D      4        0.3       4       4       4
5     E      5        0.2       5       5       5
6     F     79        0.1       5       5       5

# Do it with a with, why not, which is functionally the same, just avoids $ characters.
df$values5 = with(df,replace(values,values > 5,5)); df
  title values otherstuff values2 values3 values4 values5
1     A      1        0.6       1       1       1       1
2     B      2        0.5       2       2       2       2
3     C     33        0.4       5       5       5       5
4     D      4        0.3       4       4       4       4
5     E      5        0.2       5       5       5       5
6     F     79        0.1       5       5       5       5

I keep overthinking things in R.


  • I don't know.  It seems like a good idea, but land supply in high population areas is an issue.  This would work best in low-density/low-cost-land areas, but that seems like this has the potential to add to blight if the region loses population.  Definitely a good idea for places with land and homelessness.
  • Animals and flowers.
  • I've been reading this series as part of my "take advantage of Amazon sale"/"accidentally look like I'm committing fraud" thing.  It's very good, but I wish they hadn't split the A/B story issues into two trades.  I get that they did it so each book would have a "complete" story, but I feel like I'm missing out on the back and forth between the two.

No comments:

Post a Comment