Search code examples
pythonpandasplotplotly

Pandas Pivot chart with filtering


I have a data frame as shown below.It's name is 'df_IBIAS_mode1_FUN'

enter image description here

I need to plot a pivot chart with index='Device_ID'', columns='Temp(deg)', values='ibias_post_trim[MHz]' for all values of Supply[V]=2.5.

Below is my code for making the pivot table.

df_IBIAS_mode1_FUN[df_IBIAS_mode1_FUN.Supply[V] == 2.5].pivot_table(index='Device_ID', columns='Temp(deg)', values='ibias_post_trim[MHz')
    

This coding throwing an error as shown below.May I know where I went wrong.

*AttributeError: 'DataFrame' object has no attribute 'Supply'*

Solution

  • You will need to use quotations to access the column, as the column name contains square brackets. You are also missing a square bracket towards the end:

    df_IBIAS_mode1_FUN[df_IBIAS_mode1_FUN["Supply[V]"] == 2.5].pivot_table(index='Device_ID', columns='Temp(deg)', values='ibias_post_trim[MHz]')