Here is the dataframe pid , University 1,'American Medical University ' 1,'Bejing Univ '…
- User
Here is the dataframe pid , University 1,'American Medical University ' 1,'Bejing Univ ' 2,'Berlin Unv ' 2,'American Medical University ' 3,NaN 3,'Jakartha University'
for column University value strip the text fill NaN with 'UNKNOWN', then do one hot encoder. and save the encode as pkl to use in new Dataframe
- Assistant
- User
explain this apply(lambda x: x.toordinal() if pd.notnull(x) else 0)
- Assistant
Certainly!
The expression:
apply(lambda x: x.toordinal() if pd.notnull(x) else 0)is typically applied to a pandas Series (like a column in a DataFrame). Here's a detailed explanation:
Breakdown:
-
: This function applies a given function (here, a ) to each element of the Series.
-
- User
January 1 of year 1 in the Gregorian calendar which year is it
- Assistant
January 1 of year 1 in the Gregorian calendar refers to the very first day of year 1 AD (Anno Domini), which is the starting point of the Gregorian calendar's year numbering system.
- The calendar years go: ... 3 BC, 2 BC, 1 BC, 1 AD, 2 AD, 3 AD, ...
- There is no year 0 in the Gregorian calendar. It goes from 1 BC directly to 1 AD.
- So year 1 AD is the first year of the "common era" (CE), and January 1 of year 1 AD is the beginning of that year.
In short:
- Year: 1 AD
- Month: January
- Day: 1
This date is used as the "epoch" for the date
.toordinal()method in Python'sdatetimemodule. The.toordinal()method counts days starting from this date as day 1.