When doing data analysis with Python, how to add a new column of weeks “week” and change the date, such as “2021-03-02” to the nth week of 2021?
Introduce two methods:
the dataframe of my data is called sample, which has the feature “date”. Now add a new feature “week”
1 dt.week
sample["week"]=sample["date"].dt.week
2. Use datetimeindex
df['week'] = pd.DatetimeIndex(sample['date']).week
Read More:
- Data analysis to obtain Yahoo stock data: some problems are encountered when using panda datareader (cannot import name ‘is_ list_ Like ‘problem)
- Oracle Data Guard Ping [arc2]: heartbeat failed to connect to standby “. Error is 12514 fault analysis
- ArcGIS publishing service analysis report error unresolved 00002 data frame has no space reference
- Summary of three methods for pandas to convert dict into dataframe
- Dataframe and np.array The mutual transformation of
- Unit Android converts c# class to JSON file and reports an error
- Methods of modifying index and columns names by dataframe in pandas
- Visual domain analysis of Python GDAL
- Jetson nano uses Python to read and parse GPS data (GPRMC, gpgga).
- Python conversion hex to string, high and low data processing
- In pandas, dataframe and np.array The mutual transformation between the two
- Attributeerror: ‘dataframe’ object has no attribute ‘IX’ error
- Three methods of converting dict into dataframe by pandas
- Coursera Using python to access Web data quiz 4
- Dataframe to numpy.ndarray Related issues of
- Removing stop words —— Python Data Science CookBook
- Python export data (CSV format)
- [leetcode] 295. Find Median from Data Stream Python
- Dataframe groupby custom aggregate function