Can't Interpolate data in Pandas Pivot table

I'm trying to create a heatmap similar to:

enter image description here

But when I try this in Python code as below using Pandas interpolate on the pivot table I get errors:

import pandas as pd

import numpy as np

import matplotlib

import matplotlib.pyplot as plt

from matplotlib import rcParams

import scipy as sp

import scipy.ndimage 

from scipy import interpolate

FILE_PATH = "." def load_nut_data(file_path=FILE_PATH):
    csv_path = os.path.join(file_path, "some_file.csv")
    return pd.read_csv(csv_path, usecols = [ 'GPSLon', 'GPSLat','Count'])

nut = load_nut_data() nut.head()

Z = nut.pivot_table(index='GPSLon', columns='GPSLat',
values='Count').T.values 

X_unique = np.sort(nut.GPSLon.unique()) Y_unique =
np.sort(nut.GPSLat.unique()) X, Y = np.meshgrid(X_unique, Y_unique)

figure = plt.figure() ax = figure.add_subplot(111) contour =
ax.contourf(X, Y, Z, cmap=plt.cm.jet)

plt.show()

Any help or tips would be appreciated.



from Recent Questions - Stack Overflow https://ift.tt/3pVN0vg
https://ift.tt/3pLbKGA

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations