Linear regression to predict the temperature of a city

In this section, we are going to use another file. The file is found in the directory for Chapter 14, Modeling Weather Data Points with Python. The file is called GlobalLandTemperaturesByMajorCity.csv.

Let's import the file into our notebook:

#reading the file and collecting only the timestamp and the year dframe= pd.read_csv('GlobalLandTemperaturesByMajorCity.csv')df_ny = dframe[dframe['City']=='New York']df_ny= df_ny.iloc[:, :2]

It is always a good idea to examine the first few entries to see how our dataset looks. This can be done using a head function:

df_ny.head(10)

The output should look like the following:

Screenshot 14.8: First 10 entries from the file

Now, we can select only ...

Get Hands-On Big Data Modeling now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.