【发布时间】:2018-02-27 07:36:32
【问题描述】:
这是我的函数调用
if __name__ == '__main__':
a = head_tail()
b = data_info_for_analysis()
c = data_visualization_chart()
d = missing_values_duplicates()
e = mapping_yes_no()
f = one_hot_encoding()
g = outlier_identification()
out2 = removing_outliers()
h = droping, features = removing_unwanted_columns(out2)
df_telecom_test, df_telecom_train, probs, clf = random_model_predictions(droping, features)
i = logistic_model_prediction(df_telecom_train, df_telecom_test, features)
j = decision_model_prediction(df_telecom_train, df_telecom_test, features)
k = fpr_tpr_thresholds(df_telecom_test, probs, clf, features)
我正在尝试将该对象保存为 json 文件
filter = "JSON File (*.json)|*.json|All Files (*.*)|*.*||"
filename = a.SaveFileName("Save JSON file as", filter)
if filename:
with open(filename, 'w') as f:
json.dump(a, f)
我收到以下错误
Traceback (most recent call last):
File "/home/volumata/PycharmProjects/Churn-Analysis/sample-object-json.py", line 429, in <module>
filename = a.SaveFileName("Save JSON file as", filter)
AttributeError: 'NoneType' object has no attribute 'SaveFileName'
我也试过另一种方法
def head_tail():
### Head of the data
print(df_telecom.head(5))
### Tail of the data
print(df_telecom.tail(5))
code_obj = head_tail()
dis.disassemble(code_obj)
尝试上述方法后,出现此错误
cell_names = co.co_cellvars + co.co_freevars
AttributeError: 'NoneType' object has no attribute 'co_cellvars'
【问题讨论】:
-
这个问题很不清楚。你现在有什么?
-
我需要将我的 python 结果转换为 json 字符串。我该怎么做,我不知道如何将其转换为 json 结果
-
如果你的输出像 dict/list 一样是 json 可序列化的,你可以使用 json 模块来转储你的结果
-
我正在将结果转换为 JSON
-
你需要返回结果(不是打印),然后使用
json.dumps(result)。
标签: python json output analysis