python - python pd.DataFrame( {'Dokuman' : docs, 'Sinif' : 类}) 中的 Pandas 数据框问题

标签 python pandas dataframe

I want to create a 2-dimensional tagged data frame. But I every time get a different error.

I use the data as in the picture. sql server query output

docs in json data

我在下面编写的代码

docs = json.loads(docs)
classes = ['internet', 'arıza', 'kesinti', 'fatura', 'fatura', 
            'telefon', 'spor', 'ekonomi']

#df_docs = pd.DataFrame({'Dokuman': docs, 'Sinif': classes})
#df_docs= pd.Series([docs, classes], index=['Dokuman','Sinif'])
#df_docs = pd.DataFrame.from_dict(docs)
#df_docs = pd.DataFrame({'Dokuman': docs, 'Sinif': classes})

如何在此处设置数据框?

df_docs = pd.DataFrame({'Dokuman': docs, 'Sinif': classes})

使用此代码时出现错误

最佳答案

the number of records in the docs is not equal to the number of records in the classes, so I am getting the error

问题已改善

关于python - python pd.DataFrame( {'Dokuman' : docs, 'Sinif' : 类}) 中的 Pandas 数据框问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55561799/

相关文章:

python - 在 python 3.7.2 中导入 numpy 后的 RAM 使用情况

python - 重新导入别名/阴影 python 内置方法

python - Cherrypy:如何从上传的文件中获取原始数据?

python - Pandas 通过多个字符串分隔符将列拆分为多列

python - 错误 : The truth value of a Series is ambiguous

Python Regex - 非贪婪匹配不起作用

python - pandas:使用 apply 获取具有两个最高值的列

python - 在 Pandas 中重命名系列

scala - SPARK 数据帧错误 : cannot be cast to scala. Function2,同时使用 UDF 拆分列中的字符串

python - 替换数据框中的某个值