The first step is importing the required packages. This can be done with the following code snippet:
#import the packages
import math
import pandas as pd
import numpy as np
import os
from pandas import DataFrame
from sklearn.cluster import KMeans
from sklearn import preprocessing
import matplotlib.pyplot as plt
from matplotlib import style
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
from sklearn import neighbors, datasets
style.use('ggplot')
import matplotlib.pylab as plt
from matplotlib.pylab import rcParams
from pandas import read_csv
from pandas import datetime
from matplotlib import pyplot
import sklearn
from sklearn.metrics import mean_squared_error
Once these packages are imported, let's import the file into memory:
bycountry= pd.read_csv("GlobalLandTemperaturesByCountry.csv", index_col=None)
bycountry.head(10)
The preceding snippet should display the first 10 entries from the file, as shown in the following screenshot:
Screenshot 14.1: First ten entries from the file