convert

Convert daily to weekly/monthly data with R

匿名 (未验证) 提交于 2019-12-03 02:00:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have daily prices series over a wide range of products; I want to convert to a new dataframe with weekly or monthly data. I first used xts in order to apply the to.weekly function...which works only for OHLC format. I am sure there may exist a function similar to to.weekly but for dataframe where the format is not OHLC. There a different posts already related to this as the following: Does rollapply() allow an array of results from call to function? or Averaging daily data into weekly data I am eventually using: length(bra) 1 2416 test

SQL group by day, show orders for each day

匿名 (未验证) 提交于 2019-12-03 01:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an SQL 2005 table, let's call it Orders, in the format: OrderID, OrderDate, OrderAmount 1, 25/11/2008, 10 2, 25/11/2008, 2 3, 30/1002008, 5 Then I need to produce a report table showing the ordered amount on each day in the last 7 days: Day, OrderCount, OrderAmount 25/11/2008, 2, 12 26/11/2008, 0, 0 27/11/2008, 0, 0 28/11/2008, 0, 0 29/11/2008, 0, 0 30/11/2008, 1, 5 The SQL query that would normally produce this: select count(*), sum(OrderAmount) from Orders where OrderDate>getdate()-7 group by datepart(day,OrderDate) Has a problem in

How do you convert YYYY-MM-DDTHH:mm:ss.000Z time format to MM/DD/YYYY time format in Python?

匿名 (未验证) 提交于 2019-12-03 01:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: For example, I'm trying to convert 2008-09-26T01:51:42.000Z to 09/26/2008. What's the simplest way of accomplishing this? 回答1: The easiest way is to use dateutil .parser.parse() to parse the date string into a timezone aware datetime object, then use strftime() to get the format you want. import dateutil.parser d = dateutil.parser.parse('2008-09-26T01:51:42.000Z') print(d.strftime('%m/%d/%Y')) #==> '09/26/2008' 回答2: >>> import time >>> timestamp = "2008-09-26T01:51:42.000Z" >>> ts = time.strptime(timestamp[:19], "%Y-%m-%dT%H:%M:%S") >>> time

Pandas - convert strings to time without date

匿名 (未验证) 提交于 2019-12-03 01:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've read loads of SO answers but can't find a clear solution. I have this data in a df called day1 which represents hours: 1 10:53 2 12:17 3 14:46 4 16:36 5 18:39 6 20:31 7 22:28 Name: time, dtype: object> I want to convert it into a time format. But when I do this: day1.time = pd.to_datetime(day1.time, format='H%:M%') The result includes today's date: 1 2015-09-03 10:53:00 2 2015-09-03 12:17:00 3 2015-09-03 14:46:00 4 2015-09-03 16:36:00 5 2015-09-03 18:39:00 6 2015-09-03 20:31:00 7 2015-09-03 22:28:00 Name: time, dtype: datetime64[ns]> It

Convert java project into android project on Eclipse [duplicate]

匿名 (未验证) 提交于 2019-12-03 01:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: Convert existing project into Android project in Eclipse? 7 answers I have seen a question about converting android to java project. Now I want to know about Converting Java project into Android Project. Is there any way? Thanks 回答1: First Way Install ADT plugin Right click on java project Select Android > Convert to Android project. Supply /res folder, /AndroidManifest.xml and /default.properties if needed. Second Way: UPD Actually, the "First Way" doesn't work with latest ADT plugin versions, for

SQL SERVER DATETIME FORMAT

匿名 (未验证) 提交于 2019-12-03 01:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Studying SQL Server there is something I am not sure of: A datetime field with the value: 2012-02-26 09:34:00.000 If I select out of the table using: CAST(dob2 AS VARCHAR(12) ) AS d1 It formats it as: Feb 26 2012 What I am unsure of his how or why SQL Server formats DateTime like that. If you use datetime2 it does not - anyone know why? 回答1: The default date format depends on the language setting for the database server. You can also change it per session , like: set language french select cast(getdate() as varchar(50)) --> févr 8 2013 9

How does one convert a grayscale image to RGB in OpenCV (Python) for visualizing contours after processing an image in binary?

匿名 (未验证) 提交于 2019-12-03 01:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am learning image processing using OpenCV for a realtime application. I did some thresholding on an image and want to label the contours in green, but they aren't showing up in green because my image is in black and white. Early in the program I used gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) to convert from RGB to grayscale, but to go back I am confused, and the function backtorgb = cv2.cvtColor(gray,cv2.CV_GRAY2RGB) is giving AttributeError: 'module' object has no attribute 'CV_GRAY2RGB'. The code below does not appear to be drawing

php imagick convert PNG to jpg

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: $image = "[...]" ; //binary string containing PNG image $file = fopen ( 'image.tmp' , 'wb' ); fputs ( $file , $image ); fclose ( $file ); $image = new Imagick ( 'PNG:image.tmp' ); $image -> thumbnailImage ( $width , $height ); $image -> setImageFormat ( 'jpg' ); $image -> setCompressionQuality ( 97 ); $image -> writeImage ( 'image.jpg' ); The above doesn't work and gives me a black image for this image. When doing instead [...] $image -> setImageFormat ( 'png' ); $image -> setCompressionQuality ( 97 ); $image -> writeImage ( 'image

How do I convert RFC822 to a python datetime object?

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I know how to do this the other way around... it would be: >>> dt.rfc822() 'Sun, 09 Mar 1997 13:45:00 -0500' 回答1: In [1]: import rfc822 # This only works for python 2 series In [2]: rfc822.parsedate_tz('Sun, 09 Mar 1997 13:45:00 -0500') Out[2]: (1997, 3, 9, 13, 45, 0, 0, 1, 0, -18000) in python3 parsedate_tz has moved to email.utils >>> import email.utils # this works on Python2.5 and up >>> email.utils.parsedate_tz('Sun, 09 Mar 1997 13:45:00 -0500') (1997, 3, 9, 13, 45, 0, 0, 1, -1, -18000) 回答2: As of python 3.3 there is email.utils

Convert Hex to RGBA

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My fiddle - http://jsbin.com/pitu/1/edit I wanted to try an easy hex to rgba conversion. Ever browser I've used renders colors using rgb as default so when using the farbtastic color picker I'm converting the hex value to rgb by grabbing the background color the hex value generates (as rgb by default = simple conversion) I tried replacing the ) symbol to , 1) , but that didn't work so I went to just see how converting rgb to rgba would work, and I'm still having trouble. The jquery $('.torgb').val($('#color').css('background-color')); $('