date-formatting

Format column within dplyr chain

*爱你&永不变心* 提交于 2019-12-03 23:23:22
I have this data set: dat <- structure(list(date = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L), .Label = c("3/31/2014", "4/1/2014", "4/2/2014", "4/3/2014"), class = "factor"), site = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L), .Label = c("a", "b"), class = "factor"), clicks = c(73L, 64L, 80L, 58L, 58L, 61L, 70L, 60L, 84L, 65L, 77L), impressions = c(55817L, 78027L, 77017L, 68797L, 92437L, 94259L, 88418L, 55420L, 69866L, 86767L, 92088L)), .Names = c("date", "site", "clicks", "impressions"), class = "data.frame", row.names = c(NA, -11L)) dat date site clicks impressions 1

Convert a time span in seconds to formatted time in shell

天大地大妈咪最大 提交于 2019-12-03 08:14:47
问题 I have a variable of $i which is seconds in a shell script, and I am trying to convert it to 24 HOUR HH:MM:SS. Is this possible in shell? 回答1: Here's a fun hacky way to do exactly what you are looking for =) date -u -d @${i} +"%T" Explanation: The date utility allows you to specify a time, from string, in seconds since 1970-01-01 00:00:00 UTC, and output it in whatever format you specify. The -u option is to display UTC time, so it doesn't factor in timezone offsets (since start time from

Setting Time in Excel using POI

爱⌒轻易说出口 提交于 2019-12-03 07:54:05
I am trying to create an Excel Work sheet using POI api in Java. In that Excel Work Sheet I want to have a cell with TIME alone. By setting this we can include the cell in summation of that particuluar column as we do in number columns. For this we need to format the cell as Time >> 13:30:55. (The internal format is 'h:mm:ss;@' ). And we need to remove the date part from the cell. When I read the cell the cell value using the POI, it is returning as 'Sun Dec 31 01:00:00 IST 1899' ( When i set the value as 1:00 ), the cell format index is 166 and the cell format string is 'h:mm:ss;@'. After

Speed-improvement on large pandas read_csv with datetime index

淺唱寂寞╮ 提交于 2019-12-03 04:36:31
问题 I have enormous files that look like this: 05/31/2012,15:30:00.029,1306.25,1,E,0,,1306.25 05/31/2012,15:30:00.029,1306.25,8,E,0,,1306.25 I can easily read them using the following: pd.read_csv(gzip.open("myfile.gz"), header=None,names= ["date","time","price","size","type","zero","empty","last"], parse_dates=[[0,1]]) Is there any way to efficiently parse dates like this into pandas timestamps? If not, is there any guide for writing a cython function that can passed to date_parser= ? I tried

Get user specified long date format in UWP

好久不见. 提交于 2019-12-02 23:41:44
问题 I want to convert a date to the user set long date format. The Current Culture is en-US, but the user is able to set a long date format of his/her choice in Control panel -> Region -> Long Date. In this case, here I set the Format to Hungarian, and selected the yyyy. MMMM d. format (keeping the Current Culture in en-US). System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern returns an incorrect pattern. So does the Windows.​Globalization API. In my Package

Why there is need to add 1 to the month for this date conversion?

╄→尐↘猪︶ㄣ 提交于 2019-12-02 23:23:51
问题 I have this date variable in javascript $scope.dt and the contents is Tue Jul 08 2014 00:00:00 GMT+0800 (Malay Peninsula Standard Time) . I want to convert it to return a string that is 2014-7-8 (YYYY-MM-DD). Below is the function I wrote; function convertDate_YYYYMMDD(d) { var curr_date = d.getDate(); var curr_month = d.getMonth()+1; //why need to add one? var curr_year = d.getFullYear(); return (curr_year + "-" + curr_month + "-" + curr_date ); } It works fine. What I don't understand is

Convert string dates in java [duplicate]

末鹿安然 提交于 2019-12-02 23:22:49
问题 This question already has answers here : Comparing date strings in Java [duplicate] (6 answers) Closed 2 years ago . I need to compare two string dates in java: String date1 = "2017-05-02"; String date2 = "5/2/2017"; //formatter for the first date SimpleDateFormat formatter = new SimpleDateFormat("yyyy-mm-dd"); Date formattedDate1 = formatter.parse(date1); //formatter for the second date formatter = new SimpleDateFormat("m/d/yyyy"); Date formattedDate2 = formatter.parse(date2); //Wrong

Speed-improvement on large pandas read_csv with datetime index

ぃ、小莉子 提交于 2019-12-02 17:47:09
I have enormous files that look like this: 05/31/2012,15:30:00.029,1306.25,1,E,0,,1306.25 05/31/2012,15:30:00.029,1306.25,8,E,0,,1306.25 I can easily read them using the following: pd.read_csv(gzip.open("myfile.gz"), header=None,names= ["date","time","price","size","type","zero","empty","last"], parse_dates=[[0,1]]) Is there any way to efficiently parse dates like this into pandas timestamps? If not, is there any guide for writing a cython function that can passed to date_parser= ? I tried writing my own parser function and it still takes too long for the project I am working on. Vladimir An

Save a formatted String to a LocalDate

六月ゝ 毕业季﹏ 提交于 2019-12-02 15:41:01
问题 I have a DateConverter class: public class DateConverter extends StringConverter<LocalDate> { String pattern = "EEE, dd. MM. uuuu"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern,Locale.US); @Override public String toString(LocalDate object) { try { return formatter.format(object); } catch(Exception ex) { return ""; } } @Override public LocalDate fromString(String string) { try { return LocalDate.parse(string, formatter); } catch(Exception ex) { return null; } } public

Why is Excel changing my date display value, and how can I prevent it from doing that?

蓝咒 提交于 2019-12-02 13:03:44
问题 It seems that Excel is taking values I assign to cells, such as "Sep 15" and changing them to "15-Sep" I have code that should assign the val in the format I want ( MMM yy ): internal static string GetMMMYYFromYYYYMM(String YYYYMMVal) { // code from http://stackoverflow.com/questions/40045761/how-can-i-convert-a-string-in-the-format-yyyymm-to-mmmyy DateTime intermediateDate = DateTime.ParseExact(YYYYMMVal, "yyyyMM", CultureInfo.InvariantCulture); return intermediateDate.ToString("MMM yy"); }