[英]how to store pandas data frame into json file, while having first column name as key to access json
[英]how to access first column pandas data frame
当我接下来跑
newlist[0].main_genres
我收到这个错误
AttributeError: 'DataFrame' object has no attribute 'main_genres'
您正在工作的DataFrame
显示它使用main_genres
作为索引; 因此,您可以使用DataFrame
的index
属性引用此系列:
import pandas as pd
df = pd.DataFrame({'main_genres': [1, 2, 3], 'colors': ['red', 'white', 'blue']}).set_index('main_genres')
print(df.index)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.