Codecademy - Pandas Lesson

You’re getting ready to staff the clinic for March this year. You want to know how many visits took place in March last year, to help you prepare. Write a command that will produce a Series made up of the March data from df from all four clinic sites and save it to the variable march. #import /;../,codecademylib3 import pandas as pd df = pd.DataFrame([ ['January', 100, 100, 23, 100], ['February', 51, 45, 145, 45], ['March', 81, 96, 65, 96], ['April', 80, 80, 54, 180], ['May', 51, 54, 54, 154], ['June', 112, 109, 79, 129]], columns=['month', 'clinic_east', 'clinic_north', 'clinic_south', 'clinic_west']) print(df) ## month clinic_east clinic_north clinic_south clinic_west ## 0 January 100 100 23 100 ## 1 February 51 45 145 45 ## 2 March 81 96 65 96 ## 3 April 80 80 54 180 ## 4 May 51 54 54 154 ## 5 June 112 109 79 129 # integer location within dataframe # locations are zero indexed and doesn't include the ending integer march = df. [Read More]
Python 

Macbook air m1 power consumption

I found that rsessions-arm64 was running the cpu at 100% and using almost 7 watts (it’s around 20 mW when idle), and ran my laptop battery down very quickly. A restart seem to have solved the problem.

Using command “sudo powermetrics” in terminal opens up the powermetrics program that’s included in osx and provides data on power usage as shown in the following screenshot:

powermetrics

Datacamp's tidyverse course using gapminder dataset

Datacamp’s Tidyverse course using Gapminder dataset library(gapminder) library(dplyr) ## Warning: package 'dplyr' was built under R version 4.2.3 ## ## Attaching package: 'dplyr' ## The following objects are masked from 'package:stats': ## ## filter, lag ## The following objects are masked from 'package:base': ## ## intersect, setdiff, setequal, union head(gapminder) ## # A tibble: 6 × 6 ## country continent year lifeExp pop gdpPercap ## <fct> <fct> <int> <dbl> <int> <dbl> ## 1 Afghanistan Asia 1952 28. [Read More]
R 

Global size of agriculture insurance market in 2020 and beyond

People often ask me how large is the world wide agriculture insurance market. U.S., Canada, China, and India have large government subsidized programs and provide reports on premiums. However, the reports do not contain privately sold products and premiums. These are mostly hail and top-up programs that complement the government subsidized crop and livestock insurance programs. Roman Shynkarenko provided the post below on Linkedin for the agriculture insurance market in 2020 according to Allianz (32bn world wide in 2020). [Read More]

Google Data Analytics Certificate

I’ve finally completed the Coursera Google Data Analytics Certificate. I think the course is great for beginners in data analytics. For me it was a great refresher on SQL and R but the other sections were not all that useful. The course did motivate me to learn R (again) and this blog site is probably a result of that. I think the course could use more on statistical thinking and spending more time on probability since data analysts could really use that in their work. [Read More]

Ideas from programming

  • Version Control and GitHub + Main/Branches, Push/Pull/Merge
  • Functions/Modules
    • Methods should be deep.
    • Write the interface first
  • Try to minimize exceptions
    • define them away
  • Be strategic + Invest in building the future/don’t introduce bad code today
  • Write the unit test before the useful code
  • Make sure you do input validation

Running Shiny R within blogdown

I just learned that I could embed the R Shiny app into blogdown from this post. So here’s an attempt at that.

R  R Shiny 

Cat XL pricing using rate on line (ROL) curves

Making an R Shiny App to replace cumbersome Excel Spreadsheet

When I was working with stop loss reinsurance contracts the usual way to perform the pricing exercise would be to gather all the loss data, fit a loss distribution to that data, make adjustments based on seasonal outlook or other variables, and apply the limits and retentions asked by the clients/brokers. Although this is standard practice and almost second nature, another way to look at the pricing problem is from the point of view that you, as an underwriter, do not have all the information and perhaps should take into consideration market pricing. [Read More]

Quarto

Weave text and code and render into many outputs

Checking out Quarto today. It looks like a more comprehensive tool than R Markdown though it does a lot of similar things like being able to write text and include code cells (like Jupyter), but then also able to render the output into many formats (pdf, html, word, etc) using Pandoc. I guess that makes sense since it’s published by the same folks behind R Markdown and R Studio: [Read More]