## Solution:

The error `TypeError: 'numpy.ndarray' object is not callable`

means that you tried to call a numpy array as a function. We can reproduce the error like so in the repl:

```
In [16]: import numpy as np
In [17]: np.array([1,2,3])()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/user/<ipython-input-17-1abf8f3c8162> in <module>()
----> 1 np.array([1,2,3])()
TypeError: 'numpy.ndarray' object is not callable
```

### EXplanation:

If we are to assume that the error is indeed coming from the snippet of code that you posted (something that you should check,) then you must have reassigned either `pd.rolling_mean`

or `pd.rolling_std`

to a numpy array earlier in your code.

### We are actually mean

```
In [1]: import numpy as np
In [2]: import pandas as pd
In [3]: pd.rolling_mean(np.array([1,2,3]), 20, min_periods=5) # Works
Out[3]: array([ nan, nan, nan])
In [4]: pd.rolling_mean = np.array([1,2,3])
In [5]: pd.rolling_mean(np.array([1,2,3]), 20, min_periods=5) # Doesn't work anymore...
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/user/<ipython-input-5-f528129299b9> in <module>()
----> 1 pd.rolling_mean(np.array([1,2,3]), 20, min_periods=5) # Doesn't work anymore...
TypeError: 'numpy.ndarray' object is not callable
```

So, basically you need to search the rest of your codebase for `pd.rolling_mean = ...`

and/or `pd.rolling_std = ...`

to see where you may have overwritten them.

Also, if you'd like, you can put in `reload(pd)`

just before your snippet, which should make it run by restoring the value of `pd`

to what you originally imported it as, but I still **highly** recommend that you try to find where you may have reassigned the given functions.

### Avoid Loops

```
import numpy as np
data=np.loadtxt(fname="data.txt")## to load the above two column
print data
print data.sum(axis=1)
```

Avoid the for loop`for XY in xy:`

Instead read up how the numpy arrays are indexed and handled.

### The definition of `fmin`

according to scipy is:

`fmin(func, x0, args=(), **kwargs)`

The reason `fmin`

doesn't take Rs is because it isn't a callable, but an array. A callable is simply an object that implements `__call__`

, such objects are methods, anonymous functions(lambdas), classes and instantiated classes.

### Follw this below code

```
def callable_function(*vargs):
pass
class Callable:
def __init__(self, *vargs):
pass
def __call__(self, *vargs):
pass
@staticmethod
def staticcallable(*vargs):
pass
callable_lambda = lambda *vargs: None
```

All of the above are `callables`

. However, not all `callables`

can be used with `fmin`

as it expects the callable to return an `int`

or a `float`

.