Question: I have an Excel worksheet which is 250 rows by 10 column of data. My dependent variable is n\_nnld\_trp and I am trying to find which independent variables are highly correlated with it to use in a linear regression model.
[![enter image description here](https://i.stack.imgur.com/le3uT.png)](https://i.stack.imgur.com/le3uT.png)

I want to make a table like this to summarize the correlation data as well as identify any cases of multi-collinearity using the equation in the picture:
[![enter image description here](https://i.stack.imgur.com/QE6rZ.png)](https://i.stack.imgur.com/QE6rZ.png)

So far, I managed to use a pivot table to get the mean of each row with my dependent variable being n\_hhld\_trp:

```
trip_mean = pd.pivot_table(read_excel, index=['n_hhld_trip'],  
                aggfunc=np.mean)

```

print(trip\_mean.head())

I'm finding it hard to make the table of correlation as shown above and I would welcome and appreciate any help.

Answer: 
The same way you accepted a single character in the first element of the first tuple in the list; you expected a character there and just wrote a variable name `x` to bind to the value of that character.

Any time you want to accept any value1 as an argument, just use a variable name; `a` or `x` or `y` or `theCharacter`, whatever name you like.

If you write a pattern with more structure than that (like `[a]`, or `(x, y)`, or `Just a`, or `((x,y):xs)`) then you're not just accepting any argument value1, you're writing a pattern match that will only work for values that have the same "shape" as your pattern (e.g. `[a]` matches a list with only one element, `((x,y):xs)` matches a list with at least one element whose first element is a tuple of `x` and `y` and whose tail is `xs`, etc).

In your case having used the pattern `[a]` Haskell has inferred that the type of this parameter must be some sort of list. `'a'` is a `Char`, which is not a list, so this is a type error. However if you did want to pass a list there your pattern would *still* most likely be wrong. `[a]` matches a list with one and only one element; empty lists or lists longer than one won't match this pattern, so it only makes sense to use `[a]` as a pattern when you have other cases that will cover lists with zero or multiple elements. If you just want to accept any list without caring about how many elements you have, you do the same thing as for any other type: just write a variable name.

---

1 Of the right type. You're still subject to the constraints of the declared or inferred type for the function and its parameters!
Figured it out with @Silvo Mayolo 's comment
Used just a instead of [a], since I'm trying to match a single character and not a list.