series

How to do I change a Series color in Excel using C#?

£可爱£侵袭症+ 提交于 2019-12-20 01:46:00
问题 I have written a program in C# whereby it automatically generates a graph for me from a CSV file and puts it onto a new XLS file. However, I need to change the color of the Line (as it is a Line Chart) to red rather than the default blue. I am finding this extremely difficult to do and the stuff I've found online has not worked. Please can someone tell me how to do this? 回答1: Here is an example. I noticed when I tried to pass an integer that the bytes seem to be read in reverse order. So

What happens when you compare 2 pandas Series

非 Y 不嫁゛ 提交于 2019-12-19 05:04:06
问题 I ran up against unexpected behavior in pandas when comparing two series. I wanted to know if this is intended or a bug. suppose I: import pandas as pd x = pd.Series([1, 1, 1, 0, 0, 0], index=['a', 'b', 'c', 'd', 'e', 'f'], name='Value') y = pd.Series([0, 2, 0, 2, 0, 2], index=['c', 'f', 'a', 'e', 'b', 'd'], name='Value') x > y yields: a True b False c True d False e False f False Name: Value, dtype: bool which isn't what I wanted. Clearly, I expected the indexes to line up. But I have to

split a Pandas series without a multiindex

五迷三道 提交于 2019-12-19 04:20:34
问题 I would like to take a Pandas Series with a single-level index and split on that index into a dataframe with multiple columns. For instance, for input: s = pd.Series(range(10,17), index=['a','a','b','b','c','c','c']) s a 10 a 11 b 12 b 13 c 14 c 15 c 16 dtype: int64 What I would like as an output is: a b c 0 10 12 14 1 11 13 15 2 NaN NaN 16 I cannot directly use the unstack command because it requires a multiindex and I only have a single-level index. I tried putting in a dummy index that all

pandas create a series with n elements (sequential or randbetween)

流过昼夜 提交于 2019-12-18 22:32:04
问题 I am trying to create a pandas series. One column of the series should contain n sequential numbers. [1, 2, 3, ..., n] One column should contain random numbers between k and k+100 . One column should contain random selection between strings in a list. ['A', 'B', 'C', ... 'Z'] 回答1: There can be a lot of solutions. In the comments of the code block ( # ) you will find a few links for more information: import pandas as pd import numpy as np import random import string k = 5 N = 10 #http://docs

How do I turn a dataframe into a series of lists?

和自甴很熟 提交于 2019-12-18 11:53:06
问题 I have had to do this several times and I'm always frustrated. I have a dataframe: df = pd.DataFrame([[1, 2, 3, 4], [5, 6, 7, 8]], ['a', 'b'], ['A', 'B', 'C', 'D']) print df A B C D a 1 2 3 4 b 5 6 7 8 I want to turn df into: pd.Series([[1, 2, 3, 4], [5, 6, 7, 8]], ['a', 'b']) a [1, 2, 3, 4] b [5, 6, 7, 8] dtype: object I've tried df.apply(list, axis=1) Which just gets me back the same df What is a convenient/effective way to do this? 回答1: You can first convert DataFrame to numpy array by

Floor or ceiling of a pandas series in python?

柔情痞子 提交于 2019-12-18 11:40:36
问题 I have a pandas series series . If I want to get the element-wise floor or ceiling, is there a built in method or do I have to write the function and use apply? I ask because the data is big so I appreciate efficiency. Also this question has not been asked with respect to the Pandas package. 回答1: You can use NumPy's built in methods to do this: np.ceil(series) or np.floor(series) . Both return a Series object (not an array) so the index information is preserved. 回答2: You could do something

Elegant way to remove items from sequence in Python? [duplicate]

我们两清 提交于 2019-12-17 10:16:45
问题 This question already has answers here : How to remove items from a list while iterating? (30 answers) Closed 4 years ago . When I am writing code in Python, I often need to remove items from a list or other sequence type based on some criteria. I haven't found a solution that is elegant and efficient, as removing items from a list you are currently iterating through is bad. For example, you can't do this: for name in names: if name[-5:] == 'Smith': names.remove(name) I usually end up doing

Conditional Replace Pandas

☆樱花仙子☆ 提交于 2019-12-16 19:23:13
问题 I'm probably doing something very stupid, but I'm stumped. I have a dataframe, and I want to replace the values in a particular column that exceed a value with zero. I had thought this was a way of achieving this: df[df.my_channel > 20000].my_channel = 0 If I copy the channel into a new data frame it's simple: df2 = df.my_channel df2[df2 > 20000] = 0 this does exactly what I want, but seems not to work with the channel as part of the original dataframe. 回答1: .ix indexer works okay for pandas

Conditional Replace Pandas

戏子无情 提交于 2019-12-16 19:21:10
问题 I'm probably doing something very stupid, but I'm stumped. I have a dataframe, and I want to replace the values in a particular column that exceed a value with zero. I had thought this was a way of achieving this: df[df.my_channel > 20000].my_channel = 0 If I copy the channel into a new data frame it's simple: df2 = df.my_channel df2[df2 > 20000] = 0 this does exactly what I want, but seems not to work with the channel as part of the original dataframe. 回答1: .ix indexer works okay for pandas

how to insert a date series in postgreSQL

喜夏-厌秋 提交于 2019-12-14 02:10:43
问题 I want to insert a Date series into an existing table ( public.test ) in the column( day ) starting from 2015-04-01 ,2015-04-02 ,.....to 2015-04-30.i know there is a generate series method in postgreSQL.But Can I generate dates using that or is there any other method to generate Dates?Any help is appreciated. 回答1: smth like insert into public.test ("day") select generate_series('2015-04-01'::date,'2015-04-30'::date,'1 day'::interval); should work 来源: https://stackoverflow.com/questions