Python Forum
How to only extract upper or lower triangular matrix into tabular form
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to only extract upper or lower triangular matrix into tabular form
#1
Hi,

I have correlation matrix as below

my raw data is stored in variable "x"

x:
A B C D
1.2 2.3 5.6 1.0
1.3 5.6 2.3 2.9
5.6 0.7 3.9 2.8
1.3 1.9 2.8 0.8
3.3 0.9 2.8 1.3
4.3 0.6 1.3 2.8
7.3 2.8 0.05 2.8
2.3 2.8 1.03 0.6

import seaborn as sns
f,ax=plt.subplots(figsize=(10,10))
corr=x.corr()
sns.heatmap(corr,mask=np.zeros_like(corr,dtype=np.bool),cmap=sns.diverging_palette(220,10,as_cmap=True),square=True,ax,ax)

a=x.corr()
b=x.corr()
corrFilter=x.corr()
s=corrFilter.unstack()
so=s.sort_values(kind="quicksort")
I want to remove diagonal, and only extract upper or lower triangular matrix. I use the below code, but it still retain for example B-->A (But it same as A-->B).
How to remove duplicate in reverse order(meaning, just retain A-->B, and omit B-->A)
Reply


Messages In This Thread
How to only extract upper or lower triangular matrix into tabular form - by SriRajesh - Jan-02-2019, 12:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Export data from PDF as tabular format zinho 5 750 Nov-11-2023, 08:23 AM
Last Post: Pedroski55
  Check if two matrix are equal and of not add the matrix to the list quest 3 878 Jul-10-2023, 02:41 AM
Last Post: deanhystad
  How to apply function lower() to the list? Toltimtixma 2 808 Feb-10-2023, 05:15 PM
Last Post: Toltimtixma
  Replace with upper(string) WJSwan 7 1,625 Feb-10-2023, 10:28 AM
Last Post: WJSwan
  Beginner Higher Lower Game wallytan 2 1,639 Sep-29-2022, 05:14 PM
Last Post: deanhystad
  AttributeError: 'list' object has no attribute 'upper' Anldra12 4 4,974 Apr-27-2022, 09:27 AM
Last Post: Anldra12
  Build a matrix by pressing buttons of an interface in Tkinter which extract data from juandiegopulla 1 1,987 Sep-13-2021, 07:28 PM
Last Post: deanhystad
  How to multiply a matrix with herself, until the zero matrix results peanutbutterandjelly 3 3,403 May-03-2021, 06:30 AM
Last Post: Gribouillis
  How can I add string.upper() noahneature 2 1,895 Oct-11-2020, 06:41 PM
Last Post: noahneature
  lower() applied at in operator Beerforfree 3 2,368 Mar-22-2020, 11:51 AM
Last Post: ndc85430

Forum Jump:

User Panel Messages

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