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:
- Solution of error converting data type varchar to datetime in SQL Server
- Error converting data type nvarchar to datetime
- Arithmetical overflow error converting expression to data type datetime
- Three methods of converting dict into dataframe by pandas
- Mybatis integrates Oracle query and reports an error in the datetime type field
- ‘Conversion failed when converting date and/or time from character string.DB-Lib error message 241,
- No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.la
- TSLint:object access via string literals is disallowedtslint(no-string-literal)
- Type error: cannot unpack non Iterable non type object appears when starting Bert server in Ubuntu system
- Arithmetic overflow error converting identity to data type int
- Methods of modifying index and columns names by dataframe in pandas
- Caused by the “error string in namespace std does not name a type” error
- After introducing sass into Vue project, start to report error typeerror [err]_ INVALID_ ARG_ Type]: the “path” argument must be of type string
- Failed to convert value of type ‘java.lang.String‘ to required type ‘java.util.Date‘;
- Arithmetic overflow error converting numeric to data type numeric.
- Solve the problem of error: cannot pass objects of non trivially copyable type ‘STD:: String’ in C / C + +
- In pandas, dataframe and np.array The mutual transformation between the two
- Problem solving: Pandas: keyerror: [ ] not in index
- Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column xxxx
- A repeated string is composed of two identical strings. For example, abcabc is a repeated string with length of 6, while abcba does not have a duplicate string. Given any string, please help Xiaoqiang find the longest repeated substring.