Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 살려줘
- 태블로
- 오류
- 이전날짜제거
- 외부접속허용
- trim
- Join
- 정제
- Delete
- random.uniform
- D2E8DA72
- Tableau
- 전처리
- SQL
- 태블로퍼블릭
- 북마크
- Def
- split
- vlookup
- safe mode 해제
- mysql
- putty
- concat
- 함수
- 데이터전처리
- 아나콘다
- 파이썬
- 맵차트
- 에러
- TabPy
Archives
- Today
- Total
무던히 하다보면 느는
파이썬 코드.. 본문
for i in range(len(df['busRoute'])):
#print(len(df['busRoute'][i].split(' '))%7)
if int(len(df['busRoute'][i].split(' '))/7) == 0:
appendlst.append(df['busRoute'][i].split(' ')[0:7])
print(',,리스트갯수0,,')
elif int(len(df['busRoute'][i].split(' '))/7) == 1:
appendlst.append(df['busRoute'][i].split(' ')[0:7]) # appendlst.append(df['busRoute'][0].split(' ')[0:7])
print(',,리스트갯수1,,')
elif int(len(df['busRoute'][i].split(' '))/7) == 2:
appendlst.append(df['busRoute'][i].split(' ')[0:7])
appendlst.append(df['busRoute'][i].split(' ')[7:14])
print(',,리스트갯수2,,')
elif int(len(df['busRoute'][i].split(' '))/7) == 3: # 몫이 3
appendlst.append(df['busRoute'][i].split(' ')[0:7])
appendlst.append(df['busRoute'][i].split(' ')[7:14])
appendlst.append(df['busRoute'][i].split(' ')[14:])
print(',,리스트갯수3,,')
elif int(len(df['busRoute'][i].split(' '))/7) == 4: # 몫이 4
appendlst.append(df['busRoute'][i].split(' ')[0:7])
appendlst.append(df['busRoute'][i].split(' ')[7:14])
appendlst.append(df['busRoute'][i].split(' ')[14:22])
appendlst.append(df['busRoute'][i].split(' ')[22:])
print(',,리스트갯수4,,')
elif int(len(df['busRoute'][i].split(' '))/7) == 5: # 몫이 5
appendlst.append(df['busRoute'][i].split(' ')[0:7])
appendlst.append(df['busRoute'][i].split(' ')[7:14])
appendlst.append(df['busRoute'][i].split(' ')[14:22])
appendlst.append(df['busRoute'][i].split(' ')[22:29])
appendlst.append(df['busRoute'][i].split(' ')[29:])
print(',,리스트갯수5,,')
elif int(len(df['busRoute'][i].split(' '))/7) == 6: # 몫이 6
appendlst.append(df['busRoute'][i].split(' ')[0:7])
appendlst.append(df['busRoute'][i].split(' ')[7:14])
appendlst.append(df['busRoute'][i].split(' ')[14:22])
appendlst.append(df['busRoute'][i].split(' ')[22:29])
appendlst.append(df['busRoute'][i].split(' ')[29:36])
appendlst.append(df['busRoute'][i].split(' ')[36:])
print(',,리스트갯수6,,')
else:
print('예외')
0, 7, 14, 21, 28, 35 가 맞을 듯 (오타)
<중복수정 및 간단하게,,>
for i in range(len(df["busRoute"])):
splitted = df["busRoute"][i].split("\n")
while true:
head, tail = splitted[:7], splitted[7:]
if len(head) == 0: break
appendlist.append(head)
splitted = tail
for i in range(len(df['busRoute'])):
subdata = df['busRoute'][i].split('\n')
length = int(len(subdata) / 7)
if length >= 1 and length <= 6:
for j in range(length):
appendlist.append(subdata[j * 7:j * 7 + 7])
print("list no: ", length)
'파이썬' 카테고리의 다른 글
아이패드로 파이썬하기 (0) | 2022.12.12 |
---|---|
[파이썬/Python] kmeans 클러스터링 (0) | 2022.10.24 |
시계열 분석 및 예측 (0) | 2022.10.20 |
[파이썬/Python] xgboost (3) | 2022.08.12 |
[파이썬/Python] threshold 그리고 f1score 그래프 (0) | 2022.07.15 |