1
$\begingroup$

I am using python to do some data analysis and I need to represent the following table as a correlation matrix. The correlation value is a value between -1 and 1.

+-------------------+----------------------------------+--------------------------+
| Correlation Value |            Variable 1            |        Variable 2        |
+-------------------+----------------------------------+--------------------------+
| -0.07035          | ELECTRICAL_CONDUCTIVITY_AT_10_CM | COVER_OPEN_WATER_PERCENT |
| nan               | ELECTRICAL_CONDUCTIVITY_AT_10_CM | Heat_1988-2013_trnd      |
| nan               | ELECTRICAL_CONDUCTIVITY_AT_10_CM | 1972                     |
| -0.059789         | ELECTRICAL_CONDUCTIVITY_AT_10_CM | BEO_HC14                 |
| nan               | ELECTRICAL_CONDUCTIVITY_AT_10_CM | st_6_avg                 |
| 0.214723          | ELECTRICAL_CONDUCTIVITY_AT_10_CM | slope_angle              |
| 0.247674          | ELECTRICAL_CONDUCTIVITY_AT_10_CM | total_mn                 |
| 0.01978           | ELECTRICAL_CONDUCTIVITY_AT_10_CM | FD13_low_flux            |
| 0.136542          | ELECTRICAL_CONDUCTIVITY_AT_10_CM | 19.1.1                   |
+-------------------+----------------------------------+--------------------------+

What tool would be best to accomplish this task? I attempted to use matplotlib to create a 2d histogram but as far as I could tell it requires 2 numerical numpy arrays. Are there any other tools or functions that could create a 2d histogram depending on the level of the correlation value?

$\endgroup$
  • $\begingroup$ Is this the full table or just a subset? I can't see how to represent a correlation matrix with that. Is the table a pandas DataFrame, a numpy array or something else? $\endgroup$ – Romain Reboulleau Oct 29 '19 at 5:52
  • 1
    $\begingroup$ Perhaps you can use Pandas Pivot method to create a 2D dataframe for each pair of (Variable 1, Variable2) -> Correlation. See here pandas.pydata.org/pandas-docs/stable/user_guide/reshaping.html. $\endgroup$ – TwinPenguins Oct 29 '19 at 5:56
0
$\begingroup$

Well, if this is the whole table, I don't see how a matrix is useful, since one of the variables you're looking at doesn't change...you can use something like this to show the correlation to each category of variable 2 https://seaborn.pydata.org/generated/seaborn.countplot.html

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.