python:분리 값 작업 삭제(행동 별 데이터)
def processHold(eachsubject,directory,newfile):
filename = 'CMUDataCol/Hold/subject{0}.json'.format(eachsubject) #
with open(filename, 'r') as f:
for jsonstr in f.readlines(): #
# ,
# ,
data = json.loads(jsonstr)
#
a = numpy.array(data)
q1 = numpy.percentile(a, 25)
q3 = numpy.percentile(a, 75)
iqr = q3 - q1
#
i = 0
for item in zip(data):
# i+1
if item <= q3 + (1.5*iqr) and item >= q1 - (1.5*iqr):
i = i + 1
if i == 10:
# json data 10 ( , , !)
HoldTime = data
with open(newfile, 'a') as f: #
json.dump(HoldTime, f)
f.write('
')
보충 지식:dataframe 분리 값 처리분리 값:데이터 의 주요 부분 에서 멀리 떨 어 진 샘플(최대 값 또는 극소 값)
처리 방법:
삭제:분리 샘플 직접 삭제
샘플 채 우기:box-plot 를 사용 하여 변수의 수치 상하 계 를 정의 하고 이상 계 는 최대 값 을 채 우 며 하계 로 최소 값 을 채 웁 니 다.
#
df['average_price'].hist()
plt.show()
df[['average_price']].boxplot()
plt.show()
#
def boxplot_fill(col):
# iqr:
iqr = col.quantile(0.75)-col.quantile(0.25)
# iqr
u_th = col.quantile(0.75) + 1.5*iqr #
l_th = col.quantile(0.25) - 1.5*iqr #
# : , 。
def box_trans(x):
if x > u_th:
return u_th
elif x < l_th:
return l_th
else:
return x
return col.map(box_trans)
#
boxplot_fill(df['average_price']).hist()
#
df['average_price'] = boxplot_fill(df['average_price'])
plt.show()
이상 의 python:분리 값 작업(모든 행위 와 같은 데이터)을 삭제 하 는 것 은 바로 작은 편집 이 여러분 에 게 공유 하 는 모든 내용 입 니 다.참고 하 시기 바 랍 니 다.여러분 들 이 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
로마 숫자를 정수로 또는 그 반대로 변환그 중 하나는 로마 숫자를 정수로 변환하는 함수를 만드는 것이었고 두 번째는 그 반대를 수행하는 함수를 만드는 것이었습니다. 문자만 포함합니다'I', 'V', 'X', 'L', 'C', 'D', 'M' ; 문자열이 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.