The use of pandas advanced interface DT in Python data analysis library
編輯:Python
Series Objects and DataFrame The column data of provides cat、dt、str Three attribute interfaces (accessors), Corresponding to classification data respectively 、 Date time data and string data , Through these interfaces, specific functions can be realized quickly , It is fast . Read today pandas The official documents summarize the following commonly used api. **
1.dt.date and dt.normalize(), They all return a date Date part , That is, only the date of . But the difference is date Back to Series yes object Type of ,normalize() Back to Series yes datetime64 Type of . Here is a simple creation dataframe.
**
*
2.dt.year、dt.month、dt.day、dt.hour、dt.minute、dt.second、dt.week (dt.weekofyear and dt.week equally ) Return the year of the date respectively 、 month 、 Japan 、 Hours 、 branch 、 Seconds and the week of the year
*
3.dt.weekday(dt.dayofweek equally ) Returns the day of the week ,0 On behalf of Monday ,6 For Sunday ,dt.weekday_name Return to the English of the day of the week .
4.dt.dayofyear Return to the day of the year ,dt.quarter Get what quarter each date is .
5.dt.is_month_start and dt.is_month_end Determine whether the date is the first or last day of each month , Can be month Switch to year and quarter Whether the corresponding judgment date is the first or last day of each year or quarter .
6.dt.is_leap_year Determine if it's a leap year
7.dt.month_name() Return the English name of the month .