2
내 팬더 데이터 프레임이 매우 커서 한 명령으로 실행되도록 textLower (프레임) 함수를 수정할 수 있어야합니다. 각 행에 대해 반복하여 각 요소에 대해 일련의 문자열 조작을 수행합니다.개별 요소를 반복하지 않고 팬더 데이터 프레임의 텍스트에 사용자 정의 함수 적용
# Function iterates over all the values of a pandas dataframe
def textLower(frame):
for index, row in frame.iterrows():
row['Text'] = row['Text'].lower()
# further modification on row['Text']
return frame
def tryLower():
cities = ['Chicago', 'New York', 'Portland', 'San Francisco',
'Austin', 'Boston']
dfCities = pd.DataFrame(cities, columns=['Text'])
frame = textLower(dfCities)
for index, row in frame.iterrows():
print(row['Text'])
######################### main() #########################
def main():
tryLower()
을이 작품 예 ...! 도와 주셔서 감사합니다. – Bonson