series

JavaFX LineChart: Insert new data in the middle of the chart

混江龙づ霸主 提交于 2019-12-05 20:18:16
I'm using a line chart with JavaFX: LineChart<Number, Number> lineChart = new LineChart<>(xAxis, yAxis); XYChart.Series series = new XYChart.Series(); lineChart.getData().add(series); I want to add data to the series successively, thereby the order in which the values arrive can not be predicted. For example, the index can be between 0 and the current size of the series. series.getData().add(new XYChart.Data(index, value)); Consider the following scenario: //initializing... series.getData().add(new XYChart.Data(1, 400)); series.getData().add(new XYChart.Data(3, 500)); series.getData().add(new

pandas query with a column consisting of array entries

南笙酒味 提交于 2019-12-05 20:14:10
ykp.data Out[182]: state action reward 0 [41] 5 59 1 [5] 52 48 2 [46] 35 59 3 [42] 16 12 4 [43] 37 48 5 [36] 5 59 6 [49] 52 48 7 [39] 11 23 I would like to find the row that matches [42] in the state entry so I ran ykp.data.query('state == [42]') but I get Empty DataFrame Columns: [state, action, reward] Index: [] when I should be seeing [42], 16, 12 . Can someone please tell me how I can workaround this? I need my state-values to be stored as arrays. Best to avoid pd.Series.apply here. Instead, you can use itertools.chain to construct a regular NumPy array. Then compare the array to an

gvisScatterChart define series dynamically

ε祈祈猫儿з 提交于 2019-12-05 18:25:23
I am dynamically creating a couple of gvisScatterChart s. I want to define the colors of each line, which I can do using series and the color attribute. There is nothing like an order or a fix number by which I can predefine the colors. So I want to create an array of attributes parallel to my colors and just place it at series=myColors . The problem is that gVis expects a string like: series="[{color: 'black', visibleInLegend: false}]", As soon as I create a string using the paste function gVis doesn't accept them any more and just shows a blank page as chart. (Even when marking the " using \

Access value by location in sorted pandas series with integer index

岁酱吖の 提交于 2019-12-05 15:23:56
I have a pandas Series with an integer index which I've sorted (by value), how I access values by position in this Series. For example: s_original = pd.Series({0: -0.000213, 1: 0.00031399999999999999, 2: -0.00024899999999999998, 3: -2.6999999999999999e-05, 4: 0.000122}) s_sorted = np.sort(s_original) In [3]: s_original Out[3]: 0 -0.000213 1 0.000314 2 -0.000249 3 -0.000027 4 0.000122 In [4]: s_sorted Out[4]: 2 -0.000249 0 -0.000213 3 -0.000027 4 0.000122 1 0.000314 In [5]: s_sorted[3] Out[5]: -2.6999999999999999e-05 But I would like to get the value 0.000122 i.e. the item in position 3. How

Iterate over pandas series

不羁岁月 提交于 2019-12-05 04:08:07
I want to travel round the series index In [44]: type(ed1) Out[44]: pandas.core.series.Series In [43]: for _, row in ed1.iterrows(): ...: print(row.name) and I get thie error: AtributeError: 'Series' ojbect has no attribute 'iterrows' Is series has any methods like iterrows? thank a lot Series objects define an iteritems method (the data is returned as a iterator of index-value pairs. for _, val in ed1.iteritems(): ... Alternatively, you can iterate over a list by calling tolist , for val in ed1.tolist(): ... Word of advice, iterating over pandas objects is generally discouraged. Wherever

Convert MultiIndex DataFrame to Series

心不动则不痛 提交于 2019-12-04 15:31:05
I created a multiIndex DataFrame by: df.set_index(['Field1', 'Field2'], inplace=True) If this is not a multiIndex DataFrame please tell me how to make one. I want to: Group by the same columns that are in the index Aggregate a count of each group Then return the whole thing as a Series with Field1 and Field2 as the index How do I go about doing this? ADDITIONAL INFO I have a multiIndex dataFrame that looks like this: Continent Sector Count Asia 1 4 2 1 Australia 1 1 Europe 1 1 2 3 3 2 North America 1 1 5 1 South America 5 1 How can I return this as a Series with the index of [Continent, Sector

VBA Code To Change Fill Color Of Series On Chart

江枫思渺然 提交于 2019-12-04 05:23:49
问题 Novice VBA user here. Hoping someone can help? I think this is probably quite simple but I am a noobie. I have 2 types of charts that will be populated into Excel by a BI tool and I need to colour the available series in them according to some rules. The 1st chart shows expenditure by year (year is the series), and there are varying degrees of history from a few months, up to 24 months. This means my 24mths of data right now is spread over years 2015, 2016, 2017.......next year this changes

Number of occurrence of pair of value in dataframe

我与影子孤独终老i 提交于 2019-12-04 04:49:05
I have dataframe with following columns: Name, Surname, dateOfBirth, city, country I am interested to find what is most common combination of name and surname and how much it occurs as well. Would be nice also to see list of top 10 combinations. My idea for top one was: mostFreqComb= df.groupby(['Name','Surname'])['Name'].count().argmax() But I think it is not giving me correct answer. Help would be much appreciated ! Thanks, Neb For performance implications of the below solutions, see Pandas groupby.size vs series.value_counts vs collections.Counter with multiple series . They are presented

Combining two series in pandas along their index [duplicate]

懵懂的女人 提交于 2019-12-04 04:01:20
This question already has an answer here: Combining two Series into a DataFrame in pandas 7 answers I have two series in pandas. series 1: id count_1 1 3 3 19 4 15 5 5 6 2 and series 2: id count_2 1 3 3 1 4 1 5 2 6 1 How do I combine the tables along the ids to form the below? id count_1 count_2 1 3 3 3 19 1 4 15 1 5 5 2 6 2 1 You can use concat : In [11]: s1 Out[11]: id 1 3 3 19 4 15 5 5 6 2 Name: count_1, dtype: int64 In [12]: s2 Out[12]: id 1 3 3 1 4 1 5 2 6 1 Name: count_2, dtype: int64 In [13]: pd.concat([s1, s2], axis=1) Out[13]: count_1 count_2 id 1 3 3 3 19 1 4 15 1 5 5 2 6 2 1 Note:

suppress Name dtype from python pandas describe

别来无恙 提交于 2019-12-04 03:44:58
Lets say I have r = pd.DataFrame({'A':1 , 'B':pd.Series(1,index=list(range(4)),dtype='float32')}) And r['B'].describe()[['mean','std','min','max']] gives an output : mean 1.0 std 0.0 min 1.0 max 1.0 Name: B, dtype: float64 But from the above output , how should I get rid or suppress the last line " Name:B, dtype: float64 " I figured out one way to achieve this x=r['B'].describe()[['mean','std','min','max']] print "mean ",x['mean'],"\nstd ",x['std'],"\nmin ",x['min'],"\nmax ",x['max'] which gives the desired output : mean 1.0 std 0.0 min 1.0 max 1.0 Is there any cleaner to achieve this output