datetime

I want to combine two variables into one with a date format

和自甴很熟 提交于 2021-02-05 08:44:26
问题 I have a data set with a character column for months ( MONTH ) and a numeric column indicating years ( YEAR ). In order to work with it as panel data, I need to unite these YEAR and MONTH into a variable with a date format. I have tried to change the variable MONTH to numeric format and then to merge MONTH with the column YEAR . R would not recognize it as a date variable. It currently looks like this: STATE MONTH YEAR VALUE California JAN 2018 800 California FEB 2018 780 California MAR 2018

How to change the value new Date() in java

限于喜欢 提交于 2021-02-05 08:40:19
问题 In my application, the date and time need to be changed frequently when the tester tests the application. Currently, we have to use the system command date-s to change the system time,But this will cause other applications on the server to be affected as well。I want to change the Date() only this application, and I don't want to change the application itself, because there are so many places where new Date is used 回答1: The java.util.Date API is very very old. It was replaced by the Calendar

add time units to a date without timezone

佐手、 提交于 2021-02-05 08:36:06
问题 I write these in Linux bash date -d "2018-08-21 02:00:00" +'%y-%m-%d %T' and it prints 2018-08-21 02:00:00 But when I write these date -d "2018-08-21 02:00:00 +1 hour" +'%y-%m-%d %T' it prints 2018-08-21 07:30:00 instead of 2018-08-21 03:00:00 It adds my timezone to the date . How can I ignore timezone when I'm adding time units? 回答1: What is happening is that the +1 is interpreted as the timezone UTC+1h . So it will convert your input date from UTC+1 to your local time-zone and then still

DateTime precision in .NET core

£可爱£侵袭症+ 提交于 2021-02-05 08:20:10
问题 Following Eric Lippert's post years back on precision of DateTime , I ran his test on .netcore and .NET Framework 4.5.2, on the same machine with Windows 10. var n = 1000; int i = 0; long[] diffs = new long[n]; while (i++ < n-1) { if (ticks != DateTime.Now.Ticks) { var newTicks = DateTime.UtcNow.Ticks; var diff = newTicks - ticks; diffs[i] = diff; ticks = newTicks; } } foreach (var d in diffs) { if (d == 0) Console.WriteLine("same"); else Console.WriteLine(d); } The result on .NET framework 4

DateTime precision in .NET core

丶灬走出姿态 提交于 2021-02-05 08:20:01
问题 Following Eric Lippert's post years back on precision of DateTime , I ran his test on .netcore and .NET Framework 4.5.2, on the same machine with Windows 10. var n = 1000; int i = 0; long[] diffs = new long[n]; while (i++ < n-1) { if (ticks != DateTime.Now.Ticks) { var newTicks = DateTime.UtcNow.Ticks; var diff = newTicks - ticks; diffs[i] = diff; ticks = newTicks; } } foreach (var d in diffs) { if (d == 0) Console.WriteLine("same"); else Console.WriteLine(d); } The result on .NET framework 4

timedelta64 and datetime conversion

懵懂的女人 提交于 2021-02-05 08:08:37
问题 I have two datetime (Timestamp) formatted columns in my dataframe, df['start'], df['end'] . I'd like to get the duration between the two dates. So I create the duration column df['duration'] = df['start'] - df['end'] However, now the duration column is formatted as numpy.timedelta64 , instead of datetime.timedelta as I would expect. >>> df['duration'][0] >>> numpy.timedelta64(0,'ns') While >>> df['start'][0] - df['end'][0] >>> datetime.timedelta(0) Can someone explain to me why the array

timedelta64 and datetime conversion

泄露秘密 提交于 2021-02-05 08:06:47
问题 I have two datetime (Timestamp) formatted columns in my dataframe, df['start'], df['end'] . I'd like to get the duration between the two dates. So I create the duration column df['duration'] = df['start'] - df['end'] However, now the duration column is formatted as numpy.timedelta64 , instead of datetime.timedelta as I would expect. >>> df['duration'][0] >>> numpy.timedelta64(0,'ns') While >>> df['start'][0] - df['end'][0] >>> datetime.timedelta(0) Can someone explain to me why the array

timedelta64 and datetime conversion

会有一股神秘感。 提交于 2021-02-05 08:05:30
问题 I have two datetime (Timestamp) formatted columns in my dataframe, df['start'], df['end'] . I'd like to get the duration between the two dates. So I create the duration column df['duration'] = df['start'] - df['end'] However, now the duration column is formatted as numpy.timedelta64 , instead of datetime.timedelta as I would expect. >>> df['duration'][0] >>> numpy.timedelta64(0,'ns') While >>> df['start'][0] - df['end'][0] >>> datetime.timedelta(0) Can someone explain to me why the array

timedelta64 and datetime conversion

流过昼夜 提交于 2021-02-05 08:04:01
问题 I have two datetime (Timestamp) formatted columns in my dataframe, df['start'], df['end'] . I'd like to get the duration between the two dates. So I create the duration column df['duration'] = df['start'] - df['end'] However, now the duration column is formatted as numpy.timedelta64 , instead of datetime.timedelta as I would expect. >>> df['duration'][0] >>> numpy.timedelta64(0,'ns') While >>> df['start'][0] - df['end'][0] >>> datetime.timedelta(0) Can someone explain to me why the array

Wrong Dates in Dataframe and Subplots

不羁的心 提交于 2021-02-05 07:54:30
问题 I am trying to plot my data in the csv file. Currently my dates are not shown properly in the plot also if i am converting it. How can I change it to show the proper dat format as defined Y-m-d? The second question is that I am currently plotting all the dat in one plot but want to have for every Valuegroup one subplot. My code looks like the following: import pandas as pd import matplotlib.pyplot as plt csv_loader = pd.read_csv('C:/Test.csv', encoding='cp1252', sep=';', index_col=0).dropna()