Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
3D graph
#1
Hello everyone ,
Well I'm new in Python , I have to submit an homework at university ,I'm in finance field ,it's about creating a volatility surface , so I want to use python to create it , the problem is because I don't know what's wrong in my code :


from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns


fig = plt.figure()
ax = fig.gca(projection='3d')
sur = ax.plot_surface(donnees['Time'] ,donnees['IV'],donnees['Money']) 

plt.show()


then
Error:
KeyError Traceback (most recent call last) ~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 2656 try: -> 2657 return self._engine.get_loc(key) 2658 except KeyError: pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 'Time' During handling of the above exception, another exception occurred: KeyError Traceback (most recent call last) <ipython-input-89-f6fcdf9f14c3> in <module> 1 fig = plt.figure() 2 ax = fig.gca(projection='3d') ----> 3 sur = ax.plot_surface(donnees['Time'] ,donnees['IV'],donnees['Money']) 4 5 plt.show() ~\Anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key) 2925 if self.columns.nlevels > 1: 2926 return self._getitem_multilevel(key) -> 2927 indexer = self.columns.get_loc(key) 2928 if is_integer(indexer): 2929 indexer = [indexer] ~\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 2657 return self._engine.get_loc(key) 2658 except KeyError: -> 2659 return self._engine.get_loc(self._maybe_cast_indexer(key)) 2660 indexer = self.get_indexer([key], method=method, tolerance=tolerance) 2661 if indexer.ndim > 1 or indexer.size > 1: pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 'Time'
i arlready converted my datas in float
please help
Reply


Messages In This Thread
3D graph - by erealvic - Dec-09-2019, 11:08 AM
RE: 3D graph - by sandeep_ganga - Dec-12-2019, 07:12 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020