series

python pandas : How to get the index of the values from a series that have matching values in other series?

让人想犯罪 __ 提交于 2019-12-25 02:08:51
问题 I have these two series: In [48]: serie1 Out[48]: 0 A 1 B 2 C 3 A 4 D In [49]: serie2 Out[49]: 0 X 1 Y 2 A 3 Z 4 A 5 D dtype: object And for each value in serie1 I want to get the index/indexes from serie2. Is this possible without iterating over values? A possible solution would be to build a dataframe more or less like this: A B C D X False False False False Y False False False False A True False False False Z False False False False A True False False False D False False False True ... and

Insert multiple elements into Pandas Series where similarities exist

回眸只為那壹抹淺笑 提交于 2019-12-25 01:06:26
问题 Here I'd like to insert the row "<td class='test'>None</td>" between wherever there are two rows with "href" in the tag--note, each row with href is NOT identical. import pandas as pd table = pd.Series( ["<td class='test'><a class='test' href=...", # 0 "<td class='test'>A</td>", # 1 "<td class='test'><a class='test' href=...", # 2 "<td class='test'>B</td>", # 3 "<td class='test'><a class='test' href=...", # 4 "<td class='test'><a class='test' href=...", # 5 "<td class='test'>C</td>", # 6 "<td

Hide highcharts series name on the chart

对着背影说爱祢 提交于 2019-12-24 23:59:48
问题 I am messing around with highcharts for a company project and I have the name/number from calculations (totals) being displayed int he legend. The problem is they also display on the graph. I can't for the life of me figure out how to turn them off on the chart, yet leave them on in the legend. I've read through the API and maybe I missed it but could use some help if you all don't mind. Code: Highcharts.chart('high_charts_admin', { title: { text: 'Adset ID: '+results[1].data[0].adset_id, },

symsum function error - invalid indexing or function definition?

一笑奈何 提交于 2019-12-24 21:16:51
问题 I'm attempting to sum the following using the symsum function in MATLAB: sum (from q=0 to 5) [a(q+1)*x(2)^q] where a=[a0, a1, ..., a5], x=[x(1), x(2), ...] where x(1), x(2), ... are scalars. The sum is a0 + a1x(2)+a2x(2)^2 +...+a5x(2)^5. I've used the following code: syms q a x f=a(q+1)*x(2)^q symsum(f, q, 0, 5) where x(2)= -4.9. However, the above code returns "Invalid indexing or function definition". Using f=x(2)^q does not result in the error, however, using f=a(q+1) does return the error

Jqplot different kinds of rendering in one chart

僤鯓⒐⒋嵵緔 提交于 2019-12-24 20:28:26
问题 I would like to build somthing like the chart in the sample: barLineAnimated.html. my problem is; i have more then 1 series, which i like to render as bars, and one should be rendered as line. I can't undestand the sample: one the 2 series in the sample will be rendered in different way. How can i set the kind of rendering for the single series? 回答1: Try this inside the jqplot constructor: seriesDefaults : { renderer: $.jqplot.BarRenderer, rendererOptions : { barWidth: 30 } }, series : [{}, {

Applying custom function while grouping returns NaN

本小妞迷上赌 提交于 2019-12-24 17:04:23
问题 Given a dict, performances , storing Series of kind: 2015-02-28 NaN 2015-03-02 100.000000 2015-03-03 98.997117 2015-03-04 98.909215 2015-03-05 99.909979 2015-03-06 100.161486 2015-03-09 100.502772 2015-03-10 101.685314 2015-03-11 102.518433 2015-03-12 102.427237 2015-03-13 103.424257 2015-03-16 102.669184 2015-03-17 102.181841 2015-03-18 102.436339 2015-03-19 102.672482 2015-03-20 102.238386 2015-03-23 101.460082 ... I want to group them by month, but only pick the first value which is not np

Applying custom function while grouping returns NaN

做~自己de王妃 提交于 2019-12-24 17:03:37
问题 Given a dict, performances , storing Series of kind: 2015-02-28 NaN 2015-03-02 100.000000 2015-03-03 98.997117 2015-03-04 98.909215 2015-03-05 99.909979 2015-03-06 100.161486 2015-03-09 100.502772 2015-03-10 101.685314 2015-03-11 102.518433 2015-03-12 102.427237 2015-03-13 103.424257 2015-03-16 102.669184 2015-03-17 102.181841 2015-03-18 102.436339 2015-03-19 102.672482 2015-03-20 102.238386 2015-03-23 101.460082 ... I want to group them by month, but only pick the first value which is not np

Filling NaN by 'ffill' and 'interpolate' depending on time of the day of NaN occurrence in Python

血红的双手。 提交于 2019-12-24 15:42:47
问题 I want to fill NaN in a df using 'mean' and 'interpolate' depending on at what time of the day the NaN occur. As you can see below, the first NaN occur at 6 am and the second NaN is at 8 am. 02/03/2016 05:00 8 02/03/2016 06:00 NaN 02/03/2016 07:00 1 02/03/2016 08:00 NaN 02/03/2016 09:00 3 My df consists of thousand of days. I want to apply 'ffill' for any NaN occur before 7 am and apply 'interpolate' for those occur after 7 am. My data is from 6 am to 6 pm. My attempt is: df_imputed = (df

Taylor Series Difference between exp(-x) and exp(+x)

微笑、不失礼 提交于 2019-12-24 13:40:15
问题 I'm trying to write a program which calculates the Taylor series of exp(-x) and exp(x) up to 200 iterations, for large x. (exp(x)=1+x+x^2/2+...). My program is really simple, and it seems like it should work perfectly. However it diverges for exp(-x), but converges just fine for exp(+x). Here is my code so far: long double x = 100.0, sum = 1.0, last = 1.0; for(int i = 1; i < 200; i++) { last *= x / i; //multiply the last term in the series from the previous term by x/n sum += last; //add this

Is there any way to remove column and rows numbers from DataFrame.from_dict?

旧时模样 提交于 2019-12-24 12:56:26
问题 So, I have a problem with my dataframe from dictionary - python actually "names" my rows and columns with numbers. Here's my code: a = dict() dfList = [x for x in df['Marka'].tolist() if str(x) != 'nan'] dfSet = set(dfList) dfList123 = list(dfSet) for i in range(len(dfList123)): number = dfList.count(dfList123[i]) a[dfList123[i]]=number sorted_by_value = sorted(a.items(), key=lambda kv: kv[1], reverse=True) dataframe=pd.DataFrame.from_dict(sorted_by_value) print(dataframe) I've tried to