The most simple Machine Learning Pipeline
Creating Pivot Tables - in Python!

Get yourself some Toy-Data

I wrote a little Code Snippet that returns the “California Housing” dataset provided by sklearn as a named pandas dataframe. Ready for you to use in your applications.

1
2
3
4
5
6
7
8
9
10
11
import numpy as np
import pandas as pd
from sklearn.datasets import fetch_california_housing

dict_data = fetch_california_housing()

list_names = dict_data.feature_names
list_names.extend(dict_data.target_names)

data = np.concatenate([dict_data.data, dict_data.target.reshape(-1,1)], axis=1)
df = pd.DataFrame(data=data, columns=list_names)

I need some Data - Now!

Often times, we come up with an idea for a visualization or simply want to try out a new model we have heard off. In short: We need data.

However, this can sometimes become a tedious problem as a real world dataset might need additional cleaning, which can be too much effort for a short test or playing around. Here, a toy dataset can come in handy. There are tons of toy-data sets out there, many good ones presented by the sklearn.dataset module. In the example above I remodel the arrays provided by fetch_california into a pd.DataFrame.

For more information on the “California Housing” dataset visit sklearn.datasets.fetch_california.

Code Snippet Repository

This post is part of the Code Snippet Repository, a collection of short posts designed to make your everyday coding easier. These are based on public content from forums like stackoverflow and package documentations. You can find the code also in this repo on github!