TypeError: 'DataFrame' object is not callable on a market analysis project - dataframe

Code:
gm['MA50'] = gm['Open'].rolling(50).mean()
gm['Ma200'] = gm['Open'].rolling(200).mean()
gm('Open','MA50','MA200').plot(label='gm',figsize=(16,8))
I have been having the following error despite every way to change it and still getting the same error.
Error
--------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-35-062557c07834> in <module>
1 gm['MA50'] = gm['Open'].rolling(50).mean()
2 gm['Ma200'] = gm['Open'].rolling(200).mean()
----> 3 gm('Open','MA50','MA200').plot(label='gm',figsize=(16,8))
TypeError: 'DataFrame' object is not callable
Would need some advice to overcoming this error?

Related

TypeError: descriptor 'lower' for 'str' objects doesn't apply to a 'list' object

I wanna stemming my dataset. Before stemming, I did tokenize use nltk tokenize
You can see the output on the pic
Dataset
Col Values
But when i do stemming, it return error :
[Error][3]
TypeError Traceback (most recent call
last)
<ipython-input-102-7700a8e3235b> in <module>()
----> 1 df['Message'] = df['Message'].apply(stemmer.stem)
2 df = df[['Message', 'Category']]
3 df.head()
5 frames
/usr/local/lib/python3.7/dist-
packages/Sastrawi/Stemmer/Filter/TextNormalizer.py in
normalize_text(text)
2
3 def normalize_text(text):
----> 4 result = str.lower(text)
5 result = re.sub(r'[^a-z0-9 -]', ' ', result, flags =
re.IGNORECASE|re.MULTILINE)
6 result = re.sub(r'( +)', ' ', result, flags =
re.IGNORECASE|re.MULTILINE)
TypeError: descriptor 'lower' requires a 'str' object but received a
'list'
Hope all you guys can help me

ValueError: could not broadcast input array from shape (16,18,3) into shape (16)

I was trying to instance segment my RGB images using pixellib library. However, I encountered the problem from segmentImage function. From stacktrace, I found the issue within init.py, and I have no idea why it needs to broadcast from 3D arrays to 1D. 20 Images from another folder I tried earlier didn't counter any of these.
P.S. This was my first question on StackOverflow. if I miss any necessary details, please let me know.
for file in os.listdir(test_path):
abs_test_path = os.path.join(test_path, file)
if file.endswith('.jpg'):
filename = os.path.splitext(file)[0]
if (os.path.isfile(abs_test_path)):
out_path = out_seg_path + filename
segment_image.segmentImage(abs_test_path, show_bboxes=True,
save_extracted_objects=True,
extract_segmented_objects=True)
im_0 = cv2.imread('segmented_object_1.jpg')
cv2.imwrite(out_path + '_1.jpg', im_0)
im_1 = cv2.imread('segmented_object_2.jpg')
cv2.imwrite(out_path + '_2.jpg', im_1)
This is my error
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-835299843033> in <module>
15
16 segment_image.segmentImage(abs_test_path, show_bboxes=True,
---> 17 save_extracted_objects=True, extract_segmented_objects=True)
18
19 # segment_image.segmentImage('segmented_object_1.jpg', show_bboxes=True, output_image_name=out_path + '_1.jpg',
~\anaconda3\envs\mask_rcnn\lib\site-packages\pixellib\instance\__init__.py in segmentImage(self, image_path, show_bboxes, extract_segmented_objects, save_extracted_objects, mask_points_values, output_image_name, text_thickness, text_size, box_thickness, verbose)
762 cv2.imwrite(save_path, extracted_objects)
763
--> 764 extracted_objects = np.array(ex, dtype=object)
765
766 if mask_points_values == True:
ValueError: could not broadcast input array from shape (16,18,3) into shape (16)
There isn't enough information to help you.
I don't know what segment_image.segmentImage is, or what it expects. And I don't have your jpg file to test.
I have an idea of why the problem line raises this error, but since it occurs in an unknown function I can't suggest any fixes.
extracted_objects = np.array(ex, dtype=object)
ex probably is a list of arrays, arrays that match in some some dimensions but not others. It's trying to make an object dtype array of those arrays, but due to the mix of shapes it raises an error.
An simple example that raises the same error:
In [151]: ex = [np.ones((3, 4, 3)), np.ones((3, 5, 3))]
In [152]: np.array(ex, object)
Traceback (most recent call last):
Input In [152] in <module>
np.array(ex, object)
ValueError: could not broadcast input array from shape (3,4,3) into shape (3,)

AttributeError: 'Styler' object has no attribute 'merge'

I have a problem like that, when i styled data (conditional format) with pandas, i can't merge that datas. You can find my code and error below,
Can anyone give me an advice?
CODE:
cm = sns.diverging_palette(10, 140, s=99, l=50,
n=9, center="light", as_cmap=True)
df_style1 = df_b.style.background_gradient(cmap=cm)
df_style2 = df_c.style.background_gradient(cmap=cm)
df_last = df_style1.merge(df_style2, on= 'EKSPER_ADI', how='left')
ERROR:
AttributeError Traceback (most recent call last)
<ipython-input-148-d1b2ae3dc7a6> in <module>
4 df_style1 = df_b.style.background_gradient(cmap=cm)
5 df_style2 = df_c.style.background_gradient(cmap=cm)
----> 6 df_last = df_style1.merge(df_style1, on= 'EKSPER_ADI', how='left')
AttributeError: 'Styler' object has no attribute 'merge'
I think not possible, first use merge and then apply styles:
df = df_b.merge(df_c, on= 'EKSPER_ADI', how='left')
df_style2 = df.style.background_gradient(cmap=cm)

TypeError: 'numpy.float64' object is not callable during normalization

I'm performing feature scaling(normalization) on my dataset, using below code:
Nomalisation
for i in cnames:
print(i)
churn_train[i] = (churn_train[i] - min(churn_train[i]))/(max(churn_train[i]) - min(churn_train[i]))
But, i am getting the error:
TypeError Traceback (most recent call
last)
in ()
2 for i in cnames:
3 print(i)
----> 4 churn_train[i] = (churn_train[i] - min(churn_train[i]))/(max(churn_train[i]) - min(churn_train[i]))
TypeError: 'numpy.float64' object is not callable
try below code in python
for i in cnames:
print(i)
churn_train[i] = (churn_train[i] - churn_train[i].min())/(churn_train[i].max()) - min(churn_train[i]))

tf.contrib.learn yields error message "module has no attribute 'learn' "

Here is a snippet of my code taken directly from the tf.contrib.learn tutorial on tensorflow.org:
# Load Data Sets
training_set = tf.contrib.learn.datasets.base.load_csv_with_header(
filename = IRIS_TRAINING,
target_dtype = np.int,
features_dtype = np.float32)
Here is the error message:
AttributeError Traceback (most recent call last)
<ipython-input-14-7122d1244c55> in <module>()
11
12 # Load Data Sets
---> 13 training_set = tf.contrib.learn.datasets.base.load_csv_with_header(
14 filename = IRIS_TRAINING,
15 target_dtype = np.int,
AttributeError: 'module' object has no attribute 'learn'
Clearly the module has the attribute learn since tensorflow has a section on learning tf.contrib.learn. What am I doing wrong? All guidance is appreciated.