Split () positive sequence split column; Rsplit () split column in reverse order
Series.str.split (Pat=none, N=-1, Expand=false)
Parameters:
Pat: string, default use of white space split.
N: Integer, default to-1, use all split points to split
Expand: Boolean value, default to False. Returns a data box (Dataframe) or a complex index (MULTIINDEX) if true, or a sequence (Series) or index (indexed) if it is.
Return_type: Discard, use Spand parameter instead
return value:
Split: Reference Expand Parameters
Example:
Divide the list by the first space into two lists, which are named "Property" and "Description".
Property Description |
Year of the DateTime |
Month the month of the DateTime |
Day of the DateTime |
Hour The hour of the DateTime |
Minute the minutes of the DateTime |
Second the seconds of the DateTime |
Microsecond the microseconds of the DateTime |
Nanosecond the nanoseconds of the DateTime |
Date Returns datetime.date (does not contain timezone information) |
Time Returns Datetime.time (does not contain timezone information) |
DayOfYear the ordinal day of the year |
WeekOfYear the week ordinal of the year |
Week the week ordinal of the year |
DayOfWeek the numer of the week with Monday=0, sunday=6 |
Weekday the ' Day of the ' Week with Monday=0, sunday=6 |
Weekday_name the name of the day in a week (Ex:friday) |
Quarter quarter of the Date:jan=mar = 1, Apr-jun = 2, etc. |
Days_in_month the number of days in the month of the DateTime |
Is_month_start Logical indicating if a month (defined by frequency) |
Is_month_end Logical indicating if last day of month (defined by frequency) |
Is_quarter_start Logical indicating if a quarter (defined by frequency) |
Is_quarter_end Logical indicating if last day of quarter (defined by frequency) |
Is_year_start Logical indicating if (defined by frequency) |
Is_year_end Logical indicating if last day of year (defined by frequency) |
Is_leap_year Logical indicating if the date belongs to a leap year |
Import pandas as PD
Df=pd.read_excel ("C:/users/administrator/desktop/new Microsoft Excel worksheet. xlsx") #读取工作表
DF [Property],df[' Description ']=df[' property Description '].str.split ("", n=1). str# divide by first space
Df.drop ("Property Description ", axis=1,inplace=true) #删除原有的列
df.to_csv (" C:/users/administrator/desktop/new Microsoft Excel Worksheet. csv ", Index=false) #保存为csv, and delete the index
The results are shown in the following illustration:
Property |
Description |
Year |
The year of the DateTime |
Month |
The month of the DateTime |
Day |
The days of the DateTime |
Hour |
The hour of the DateTime |
Minute |
The Minutes of the DateTime |
Second |
The Seconds of the DateTime |
Microsecond |
The microseconds of the DateTime |
Nanosecond |
The nanoseconds of the DateTime |
Date |
Returns datetime.date (does not contain timezone information) |
Time |
Returns Datetime.time (does not contain timezone information) |
DayOfYear |
The ordinal day of the year |
WeekOfYear |
The week ordinal of the year |
Week |
The week ordinal of the year |
DayOfWeek |
The numer of the week with Monday=0, sunday=6 |
Weekday |
The number of the day of the week with Monday=0, sunday=6 |
Weekday_name |
The name of the day in a week (Ex:friday) |
Quarter |
Quarter of the Date:jan=mar = 1, Apr-jun = 2, etc. |
Days_in_month |
The number of days in the month of the DateTime |
Is_month_start |
Logical indicating if a month (defined by frequency) |
Is_month_end |
Logical indicating if last day of month (defined by frequency) |
Is_quarter_start |
Logical indicating if a quarter (defined by frequency) |
Is_quarter_end |
Logical indicating if last day of quarter (defined by frequency) |
Is_year_start |
Logical indicating if (defined by frequency) |
Is_year_end |
Logical indicating if (defined by frequency) |
is_leap_year |
Logical indicating if the date belongs to a leap year |