Home > Enterprise >  DataFrame: how to draw a 3D graph using Index and Columns as x and y, and data as z?
DataFrame: how to draw a 3D graph using Index and Columns as x and y, and data as z?

Time:12-31

My DataFrame line index and column index store x and y values, while the data values are z values, i.e. f(x, y).

Let's take an example:

import pandas as pd
df = pd.DataFrame([[150, 120, 170], [190, 160, 130]],
                  index=[2, 4], columns=[10, 30, 70])
print(df)
#     10   30   70
# 2  150  120  170
# 4  190  160  130

then f(4, 30) is 160.

I would like to make a 3D plot of function f. I don't really mind if it looks like a 3D histogram or a surface plot - both answers would be appreciated.

CodePudding user response:

You need to create a enter image description here

  • Related