series

How to convert Dataframe into Series?

被刻印的时光 ゝ 提交于 2019-12-30 10:27:18
问题 I want to convert N columns into one series. How to do it effectively? Input: 0 1 2 3 0 64 98 47 58 1 80 94 81 46 2 18 43 79 84 3 57 35 81 31 Expected Output: 0 64 1 80 2 18 3 57 4 98 5 94 6 43 7 35 8 47 9 81 10 79 11 81 12 58 13 46 14 84 15 31 dtype: int64 So Far I tried: print df[0].append(df[1]).append(df[2]).append(df[3]).reset_index(drop=True) I'm not satisfied with my solution, moreover it won't work for dynamic columns. Please help me to find a better approach. 回答1: You can also use

How to map key to multiple values to dataframe column?

你离开我真会死。 提交于 2019-12-30 09:27:05
问题 I have a df column that looks like this: col1 Non Profit Other-501c3 501c3 Sole Proprietor How can I create a dictionary object or mapping layer(open to all suggestions) where I can pass any value if it matches criteria and changes to the key value? For example if the value is Other-501c3 then change it to non-profit . Examples (everything after the equal sign needs to change to the value before equal sign): 1. non-profit = (Non Profit, Other-501c3, 501c3,NON-Profit, Not-for-profit). 2. Sole

Python - Extra Excel chart series with win32com

馋奶兔 提交于 2019-12-30 07:49:58
问题 I'm writing some code for an assignment, and I need to create a simple column chart in Excel. This afternoon I found win32com (amazing tool by the way), but I've been suffering from either the lack of documentation about it, or my lack of luck to find it ^^ I'm playing around with the charts, and I think I've managed to do what I want, with a little exception: the function I wrote always creates 2 series of columns. This is what I've got: xlBook = xlApp.Workbooks.Add() xlSheet = xlBook.Sheets

Python - Extra Excel chart series with win32com

随声附和 提交于 2019-12-30 07:49:33
问题 I'm writing some code for an assignment, and I need to create a simple column chart in Excel. This afternoon I found win32com (amazing tool by the way), but I've been suffering from either the lack of documentation about it, or my lack of luck to find it ^^ I'm playing around with the charts, and I think I've managed to do what I want, with a little exception: the function I wrote always creates 2 series of columns. This is what I've got: xlBook = xlApp.Workbooks.Add() xlSheet = xlBook.Sheets

Pandas Series of lists to one series

梦想的初衷 提交于 2019-12-30 02:37:30
问题 I have a Pandas Series of lists of strings: 0 [slim, waist, man] 1 [slim, waistline] 2 [santa] As you can see, the lists vary by length. I want an efficient way to collapse this into one series 0 slim 1 waist 2 man 3 slim 4 waistline 5 santa I know I can break up the lists using series_name.split(' ') But I am having a hard time putting those strings back into one list. Thanks! 回答1: You are basically just trying to flatten a nested list here. You should just be able to iterate over the

how do I calculate a rolling idxmax

别来无恙 提交于 2019-12-28 06:25:11
问题 consider the pd.Series s import pandas as pd import numpy as np np.random.seed([3,1415]) s = pd.Series(np.random.randint(0, 10, 10), list('abcdefghij')) s a 0 b 2 c 7 d 3 e 8 f 7 g 0 h 6 i 8 j 6 dtype: int64 I want to get the index for the max value for the rolling window of 3 s.rolling(3).max() a NaN b NaN c 7.0 d 7.0 e 8.0 f 8.0 g 8.0 h 7.0 i 8.0 j 8.0 dtype: float64 What I want is a None b None c c d c e e f e g e h f i i j i dtype: object What I've done s.rolling(3).apply(np.argmax) a NaN

Control column widths in a ggplot2 graph with a series and inconsistent data

邮差的信 提交于 2019-12-28 04:27:27
问题 In the artificial data I have created for the MWE below I have tried to demonstrate the essence of a script I have created in R. As can be seen by the graph that gets produced from this code, on one of my conditions I don't have a "No" value to complete the series. I have been told that unless I can make this last column that sadly doesn't have the extra series as thin as the columns else where in the graph I won't be permitted to use these graphs. This is sadly a problem because the script I

To set dynamic data of excel chart at runtime and not Excel.Range

雨燕双飞 提交于 2019-12-25 03:53:53
问题 I want to set data for Excel chart but cannot display data in any Range. so i cannot use following function : chart.SetSourceData(range,XlRowCol) i have heared about the series but dont know how to use it I am having a List<int> list of integers and want to display a column chart with each integer value on singe column. Please help me. Any code or suggestions will do. thnx in advance 回答1: Is a List an array? You can assign 1D arrays to the .XValues and .Values of a chart series. You would

Why my code didn't select data from Pandas dataframe? [duplicate]

余生长醉 提交于 2019-12-25 03:45:07
问题 This question already has answers here : How to filter by month, day, year with Pandas (1 answer) Keep only date part when using pandas.to_datetime (8 answers) Closed last year . Why didn't my date filter work? All others filters work fine. import pandas as pd import datetime data =pd.DataFrame({ 'country': ['USA', 'USA', 'Belarus','Brazil'], 'time': ['2018-01-15 16:11:45.923570+00:00', '2018-01-15 16:19:45.923570+00:00', '2018-01-16 16:12:45.923570+00:00', '2018-01-17 16:14:45.923570+00:00']

Getting series color from LineChart

断了今生、忘了曾经 提交于 2019-12-25 02:08:53
问题 LineChart has series which have different color by default. How can I get it to set obtained color to other text connected with the specified series? 回答1: In a line chart since all elements of a single series have one color. The series are assigned with styleclass series0 , series1 , series2 etc. Each of these series are assigned with corresponding colors styleclass i.e. default-color0 , default-color1 , default-color2 etc. You can directly use the styleclass for your text/labels. 来源: https:/