import pandas as pd
from pandas import DataFrame
from dateutil.parser import parse
data
data = DataFrame(columns=['date'], data=['2020-11-01','2020-11-05','2020-11-08','2020-11-11'])
data
data.info()
"""
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 4 entries, 0 to 3
Data columns (total 1 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 date 4 non-null object
dtypes: object(1)
memory usage: 160.0+ bytes"""
conversion
data['date'] = data['date'].apply(parse)
data.info()
"""
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 4 entries, 0 to 3
Data columns (total 1 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 date 4 non-null datetime64[ns]
dtypes: datetime64[ns](1)
memory usage: 160.0 bytes
"""
Read More:
- Methods of modifying index and columns names by dataframe in pandas
- Reintex index of pandas
- Pandas generates new columns through LOC
- Pandas get column name
- Python common error: if using all scalar values, you must pass an index (four solutions)
- Summary of three methods for pandas to convert dict into dataframe
- Attributeerror: ‘dataframe’ object has no attribute ‘IX’ error
- Three methods of converting dict into dataframe by pandas
- Dataframe and np.array The mutual transformation of
- Problem solving: Pandas: keyerror: [ ] not in index
- 13. R language: Error in match.names(clabs, names(xi)): The name is not relative to the original name
- [Python] pandas Library pd.to_ Parameter arrangement and example of Excel operation writing into excel file
- data argument can’t be an iterator
- Read multiple sheets of an excel file according to npoi
- Error in .Call.graphics(C_palette2, .Call(C_palette2, NULL)) : invalid graphics state
- The solution to the error of importing CSV from Python to Python
- Origin — draw the curve with error bar
- Linux view folder size, remaining disk space (DU / DF)
- In pandas, dataframe and np.array The mutual transformation between the two
- Python data analysis dataframe converts dates to weeks