Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

형변환 #4

Open
98hyun opened this issue Jan 23, 2021 · 0 comments
Open

형변환 #4

98hyun opened this issue Jan 23, 2021 · 0 comments
Labels

Comments

@98hyun
Copy link
Contributor

98hyun commented Jan 23, 2021

numeric -> object

df[col].astype(str)

numeric -> date

규칙. 생긴대로
예를 들어 20210123 일때, pd.to_datetime(df['date'],format='%Y%m%d')
예를 들어 210123 일때, pd.to_datetime(df['date'],format='%y%m%d')
예를 들어 01/23/2021 일때, pd.to_datetime('01/23/2021',format='%m/%d/%Y')

object -> numeric

df[col].astype(int) or float
이런방법도 있는데 이상한 문자열이 포함된 특수한 경우 pd.to_numeric(df[col], errors='coerce') 로 바꾼 후, fillna(-999) 로 이상치로 넣어버리는경우도 있다.

@98hyun 98hyun added the share label Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant