string-to-datetime

How do you convert a column containing year & quarter in a str format as '1947q1' to date format column where both year and quarter are considered?

帅比萌擦擦* 提交于 2021-02-11 13:44:38
问题 **Year_qtr GDP ADJ_GDP** 2 1947q1 243.1 1934.5 3 1947q2 246.3 1932.3 4 1948q3 250.1 1930.3 5 1949q4 260.3 1960.7 Tried parse() from dateutil package but didnt wwork. Result dataframe should have 'Year_qtr' column as date values instead of object. 回答1: pandas already can do this out of the box! you can cast to datetime right away: import pandas as pd df = pd.DataFrame({'Year_qtr': ['1947q1', '1947q2', '1948q3', '1949q4']}) df['datetime'] = pd.to_datetime(df['Year_qtr']) # df # Year_qtr

Convert string to date using moment.js [duplicate]

一世执手 提交于 2021-01-29 06:45:28
问题 This question already has answers here : Moment.js - how do I build moment from date and time string? (2 answers) Closed 3 years ago . This my model.ts export class Feature2 { requestRouteTemplate: string; requestMethod: string; numberCount: number; requestDate: date; constructor(values: Object = {}) { Object.assign(this, values); } } This is component.ts this.datas2 = [ { 'requestRouteTemplate': 'api/Tasks', 'requestMethod': 'POST', 'numberCount': 6, 'requestDate': '07/01/2017', }, {

Change dataframe column names from string format to datetime

牧云@^-^@ 提交于 2020-07-05 04:40:27
问题 I have a dataframe where the names of the columns are dates (Year-month) in the form of strings. How can I convert these names in datetime format? I tried doing this: new_cols = pd.to_datetime(df.columns) df = df[new_cols] but I get the error: KeyError: "DatetimeIndex( ['2000-01-01', '2000-02-01', '2000-03-01', '2000-04-01', '2000-05-01', '2000-06-01', '2000-07-01', '2000-08-01', '2000-09-01', '2000-10-01', '2015-11-01', '2015-12-01', '2016-01-01', '2016-02-01', '2016-03-01', '2016-04-01',

Slow pd.to_datetime()

不打扰是莪最后的温柔 提交于 2020-03-22 19:50:42
问题 I am reading two types of csv files that are very similar. They are about the same lenght, 20 000 lines. Each line represent parameters recorded each second. Thus, the first column is the timestamp. In the first file, the pattern is the following: 2018-09-24 15:38 In the second file, the pattern is the following: 2018-09-24 03:38:06 PM In both cases, the command is the same: data = pd.read_csv(file) data['Timestamp'] = pd.to_datetime(data['Timestamp']) I check the execution time for both

Slow pd.to_datetime()

十年热恋 提交于 2020-03-22 19:41:34
问题 I am reading two types of csv files that are very similar. They are about the same lenght, 20 000 lines. Each line represent parameters recorded each second. Thus, the first column is the timestamp. In the first file, the pattern is the following: 2018-09-24 15:38 In the second file, the pattern is the following: 2018-09-24 03:38:06 PM In both cases, the command is the same: data = pd.read_csv(file) data['Timestamp'] = pd.to_datetime(data['Timestamp']) I check the execution time for both

Slow pd.to_datetime()

雨燕双飞 提交于 2020-03-22 19:41:34
问题 I am reading two types of csv files that are very similar. They are about the same lenght, 20 000 lines. Each line represent parameters recorded each second. Thus, the first column is the timestamp. In the first file, the pattern is the following: 2018-09-24 15:38 In the second file, the pattern is the following: 2018-09-24 03:38:06 PM In both cases, the command is the same: data = pd.read_csv(file) data['Timestamp'] = pd.to_datetime(data['Timestamp']) I check the execution time for both

SQL Server: convert to today then add 8 hours

对着背影说爱祢 提交于 2020-01-05 07:13:14
问题 nextUpdate can be any date time value in the past. I'm trying to update the nextUpdate field to today's date but keeping the time unchanged and then add 8 hours. I get error converting string to datetime T-SQLe: UPDATE business.dbo.db_schedule SET nextUpdate = DATEADD(hh, 8, CONVERT(datetime, CONVERT(VARCHAR(8), GETDATE(), 111) + ' ' + CONVERT(VARCHAR(8), nextUpdate, 108), 111)) WHERE sno = 8 datetime format in my location is 111 回答1: UPDATE business.dbo.db_schedule SET nextUpdate= DATEADD(hh

str_to_date function in sql server?

喜夏-厌秋 提交于 2020-01-03 13:07:23
问题 MySQL has a function called STR_TO_DATE, that converts a string to date. Question: Is there a similar function in SQL Server? 回答1: If you need to parse a particular format, use CONVERT(datetime, @mystring, @format) . Use this as a reference: http://www.sqlusa.com/bestpractices/datetimeconversion/ 回答2: What if the string is 7/7/2010? Then use CONVERT with either 101 (mm/dd/yy) or 103 (dd/mm/yy) depending on what you want: SELECT CONVERT(DATE, '7/7/2010', 103) Result: 2010-07-07 回答3: Use CAST.

Cannot convert string to date for datePicker

血红的双手。 提交于 2019-12-25 17:20:16
问题 I try to get string from textfield, then convert it to date and put this value in datepicker. But for some reason it fails everytime and I get: "There is issue in dateformatter. Not able to convert string to Date". I don't understand what I'm doing wrong and how I get this works. My code: import UIKit class ViewController: UIViewController { @IBOutlet weak var DOBTextField: UITextField! override func viewDidLoad() { super.viewDidLoad() DOBTextField.addInputViewDatePicker(target: self,

Using STR_TO_DATE in Java to INSERT Date, with PreparedStatement

空扰寡人 提交于 2019-12-25 02:24:07
问题 Let's suppose we have a JFrame called FrmRegistration . Its function is inserting data into a table called records . MySQL's command desc records would result the following: +-----------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+--------------+------+-----+---------+-------+ | id | varchar(7) | NO | PRI | | | | name | varchar(100) | NO | | NULL | | | birthday | date | NO | | NULL | | +-----------+--------------+------+-----+---