강의

멘토링

커뮤니티

Inflearn Community Q&A

ldskoo12036160's profile image
ldskoo12036160

asked

Pandas Pandas Data Analysis Basics Practice

Create a data frame

attributeError가 발생합니다

Written on

·

716

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

Answer 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) )

로 수정하면 되더라구요.

ldskoo12036160's profile image
ldskoo12036160

asked

Ask a question