본문 바로가기
AI(artificial Intelligence)

AI-Data Manipulation

by 데이터 퍼즐 2021. 5. 10.
반응형

Top25pandas tricks

 

1.show installed versions : pd._version_ / pd.show_versions()

2.create an example dataframe : df=pd.Dataframe({'col cone': {100,200}, 'col two':{300,400}})

3.Rename columns

4.Reverse row order [::-1] index 변환, 재변환

5.Reverse column order

6.Select columns by data type

7.Convert strings to numbers

8.Reduce DataFrame size

9.Build a DataFrame from multiple files (row-wise)

10.Build a DataFrame from multiple files(column-wise)

11.Create a DataFrame frome the clipboard

12.Split a DataFrame from the clipboard

13.Fliter a DataFrame by multiiple categories

14.Split a DataFrame into????

15.Handle missing value

16.Split a string into multiple columns

17.Expand a Series of lists into a DataFrame

18.Aggregate by multiple functions

19.Combine the output of an aaggregation with a DataFrame

20.Select a slice of rows and columns

21.Reshape a Mutilinedexed Series

22.Create a pivot table

23.Convert continuous data into categorcal data

24.Change display options

25.Style a DataFrame

 

...

---------------------------------------------------------------------------------------------------------------------

 

 

 

데이터를 합치고 tidy로 변환하기 concat
pandas 자료형(시리즈와 데이터 프레임)

데이터 첫줄을 모름

set_index
index_col = 0
iloc 
skiprow
axis=축

cocet의 방향
merge on??
tidy data?
한줄로 나타내는 포멧팅
시각화하기 위한 필수 과정

melt:녹여내다
피봇:반대로 묶어내다

* 판다스에서는 행으로 붙인다를 디폴드

 

-1 맨 마지막 행부터 선택

 

#numpy는 리스트 대신 배열 만드는데 빠르고, 반복문 사용x, 전체 일괄 연산작용 가능해 유연성 높음

 

#Chaining은 .으로 표현한다

#Chaining이 되지 않으면 Series, DataFrames 또는 GroupBy 개체를 예상하는 함수를 함께 연결할 때 사용한다

ㄴ+: 가독성 , -: 디버깅의 어려움

 

 

(((오늘 과제 거의 못함)))

 

 

```백틱 3번
insert code

------------------------------------------------------------------

 

<Data Manipulation>

나라별 평균PPP

join_d4.groupby('geo')[["PPP"]].agg(['mean'])(x)

df4.groupby('geo').mean('PPP')[['PPP']]

 

반응형

'AI(artificial Intelligence)' 카테고리의 다른 글

AI- High dimensional data  (0) 2021.05.25
AI-Section 1 : Introduction to Data Science-Hypothesis Test  (0) 2021.05.14
AI-미분, 경사하강법  (0) 2021.05.12
AI-Feature Engineering  (0) 2021.05.10
AI (EDA)  (0) 2021.05.07

댓글