왜 명시된 변환 후에도 선택한 열의 모든 항목이 문자열이지만 팬더에서 개체가 있다고 알려주는 이유는 무엇입니까? 그 중DataFrame의 문자열이지만 dtype이 개체
<class 'pandas.core.frame.DataFrame'>
Int64Index: 56992 entries, 0 to 56991
Data columns (total 7 columns):
id 56992 non-null values
attr1 56992 non-null values
attr2 56992 non-null values
attr3 56992 non-null values
attr4 56992 non-null values
attr5 56992 non-null values
attr6 56992 non-null values
dtypes: int64(2), object(5)
다섯 dtype object
같습니다
이
내 DataFrame입니다. 나는 명시 적으로 문자열로 해당 개체를 변환 :type(df["attr2"].ix[0]
가 정확한지,
str
을 알 수 있지만
for c in df.columns:
if df[c].dtype == object:
print "convert ", df[c].name, " to string"
df[c] = df[c].astype(str)
그런 다음, df["attr2"]
여전히 dtype object
있다.
팬더는 int64
과 float64
및 object
을 구별합니다. dtype str
이 없을 때 그 뒤에있는 논리는 무엇입니까? object
으로 인해 str
이 처리되는 이유는 무엇입니까?
그래서 나는 당신이, IS 무슨 말을하는지 생각 "걱정하지 마십시오. 그것은 다음과 같이해야하는데?" –