reindex

Reindex array by increasing and decreasing all of top indexes

独自空忆成欢 提交于 2019-12-12 04:07:43
问题 First, I have to list what I have found How to Remove Array Element and Then Re-Index Array? PHP reindex array? They did not make sense in my case. I have fallen into ridiculous request and I've force to find the way out, then please don't ask me why I want to do that. I have below array $input = array( 0=>array('a', 'b'=>array('c')), 1=>array('b', 'c'=>array('d')), 2=>array('c', 'd'=>array('e')), ); I want to increase all of keys by 1 or decrease by 1 (acceptable to index is negative int

pandas re-indexing with missing dates

跟風遠走 提交于 2019-12-12 03:37:18
问题 from dateutil.rrule import rrule, MONTHLY def fread_year_month(strt_dt, end_dt): dates = [dt for dt in rrule(MONTHLY, dtstart=strt_dt, until=end_dt)] return dates df = pd.DataFrame({ 'value' : [4,2,5,6,7,8,6,5,4,1,2,4], 'date': fread_year_month(dt.datetime(2015, 1, 1),dt.datetime(2015, 12, 1)), 'stock': ['amzn']*12 },columns=[ 'value', 'date', 'stock'] ) df2 = pd.DataFrame({ 'value' : [1,1,1,1,1], 'date': fread_year_month(dt.datetime(2015, 1, 1),dt.datetime(2015, 5, 1)), 'stock': ['msft']*5 }

Magento mass reindexing gives internal server error

徘徊边缘 提交于 2019-12-11 20:43:46
问题 How can we reindex a Magento 1.7.02 version site having more than 24,000 products and hundreds of categories? When I try to reindex the product price index in Magento Admin Index Management, it generates an internal Server Error 500. When I checked the server log for errors it shows up with messages: home2/mysitete/public_html/403.shtml [Wed Jun 04 22:15:03 2014] [error] [client 101.0.79.114] client denied by server configuration: /home2/mysitete/public_html/ultimate4wheel/app/etc/local.xml

unknown field [dest], parser not found- error coming while reindexing

馋奶兔 提交于 2019-12-11 09:02:21
问题 While indexing with the following code, error arises as unknown field parser not found: client.reindex({ body: { script: { source: { index: index, type: "_doc", query: { term: { id: id } } }, dest: { index: dest_ind } } } } 回答1: Place dest outside and not nested in script - https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html client.reindex({ body: { source: { index: index, type: "_doc", query: { term: { id: id } } }, dest: { index: dest_ind } } }) 来源: https:/

Reindex pandas DataFrame to fill missing dates

南笙酒味 提交于 2019-12-11 05:37:21
问题 I have daily data in the pandas DataFrame df with certain days missing (e.g. 1980-12-25 below). I would like to reindex the DataFrame to add those dates with NaN values. date close None 0 1980-12-12 28.75 1 1980-12-15 27.25 2 1980-12-16 25.25 3 1980-12-17 25.87 4 1980-12-18 26.63 5 1980-12-19 28.25 6 1980-12-22 29.63 7 1980-12-23 30.88 8 1980-12-24 32.50 9 1980-12-26 35.50 I have generated the list dates with the full set of dates I want. [Timestamp('1980-12-12 00:00:00'), Timestamp('1980-12

Magento - Unable to reindex Product Prices - Foreign Key Constraint Fails

北慕城南 提交于 2019-12-11 03:03:14
问题 I've just recently upgraded my magento store from 1.4.2 to 1.7.0.2.. And The upgrade went smoothly but when I try to reindex data after the upgrade.. It fails on the Product Prices.. I've tried using php shell/indexer.php --reindexall from SSH and it fails at the Product Prices with these errors (I use pastebin as the error are quite long): http://pastebin.com/iV2tuzDX From what I can see, the table catalog_product_index_tier_price is empty.. and I'm not sure if that is causing any issue? I

Reindexing a specific level of a MultiIndex dataframe

岁酱吖の 提交于 2019-12-10 14:57:24
问题 I have a DataFrame with two indices and would like to reindex it by one of the indices. from pandas_datareader import data import matplotlib.pyplot as plt import pandas as pd # Instruments to download tickers = ['AAPL'] # Online source one should use data_source = 'yahoo' # Data range start_date = '2000-01-01' end_date = '2018-01-09' # Load the desired data panel_data = data.DataReader(tickers, data_source, start_date, end_date).to_frame() panel_data.head() The reindexing goes as follows: #

Sort dataframe by string length

无人久伴 提交于 2019-12-10 13:35:56
问题 I want to sort by name length. There doesn't appear to be a key parameter for sort_values so I'm not sure how to accomplish this. Here is a test df: import pandas as pd df = pd.DataFrame({'name': ['Steve', 'Al', 'Markus', 'Greg'], 'score': [2, 4, 2, 3]}) 回答1: You can use reindex of index of Series created by len with sort_values: print (df.name.str.len()) 0 5 1 2 2 6 3 4 Name: name, dtype: int64 print (df.name.str.len().sort_values()) 1 2 3 4 0 5 2 6 Name: name, dtype: int64 s = df.name.str

Splatpacking versus array_values() to re-index an array with numeric keys

坚强是说给别人听的谎言 提交于 2019-12-10 00:34:49
问题 As of PHP7.4, there is a newly available technique to re-index an array with numeric keys. I'll call it " array re-packing " or maybe something fun like " splatpacking ". The simple process involves using the splat operator ( ... ) -- aka "spread operator" -- to unpack an array then fills a new array with with the contents. Comparison Code: (Demo) $array = [2 => 4, 5 => 3, "3" => null, -10.9 => 'foo']; var_export(array_values($array)); var_export([...$array]); Both will output: array ( 0 => 4

ALTER INDEX failed because of QUOTED_IDENTIFIER when running from sp_msForEachTable

天大地大妈咪最大 提交于 2019-12-09 09:28:47
问题 When I try to rebuild an index on a table: ALTER INDEX ALL ON [dbo].[Allocations] REBUILD that works fine. But when I call EXECUTE sp_msForEachTable 'ALTER INDEX ALL ON ? REBUILD' I reach the same same table, and it fails with: Msg 1934, Level 16, State 1, Line 2 ALTER INDEX failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query