강의

멘토링

커뮤니티

Cộng đồng Hỏi & Đáp của Inflearn

Hình ảnh hồ sơ của ldskoo12036160
ldskoo12036160

câu hỏi đã được viết

Pandas Pandas Phân tích dữ liệu Thực hành cơ bản

Tạo khung dữ liệu

attributeError가 발생합니다

Viết

·

740

0

friend_list = [
    ['name', ['John', 'Nate']],
     ['age', [20, 30]],
     ['job', ['student', 'teahcer']]
]


df = pd.DataFrame.from_items(friend_list)


위와 같이 할 경우에 아래와 같이 에러가 발생합니다.

type object 'DataFrame' has no attribute 'from_items'
pandas

Câu trả lời 1

9

API 문서 보니까 이렇게 나오네요.

Deprecated since version 0.23.0: from_items is deprecated and will be removed in a future version. Use DataFrame.from_dict(dict(items)) instead. DataFrame.from_dict(OrderedDict(items)) may be used to preserve the key order.

위의 예제에서는 

df = pd.DataFrame.from_dict( dict(friend_list) )

로 수정하면 되더라구요.

Hình ảnh hồ sơ của ldskoo12036160
ldskoo12036160

câu hỏi đã được viết

Đặt câu hỏi