Questions tagged [series]
A Series object represents a data series. This may be represented as the SeriesCollection class (Java, C#) or Series class in Python Pandas.
3,226
questions
0
votes
0
answers
10
views
pandas Series indexing [duplicate]
So I have a simple pandas series here, but the indexing is not working. The same indexing is working in many other series.
ser = pd.Series(data = ["US","Canada","Mexico"],...
-3
votes
0
answers
42
views
Convert a list of multiple series generated by using nested for loop in python to Pandas dataframe, store the result of first for loop in a single row
I need to do some operation in a spatially and temporally distributed data set.
The first two column is used for longitude and latitude and rest of the columns are used to show the time where the time ...
1
vote
3
answers
54
views
How to pull a key from a dict (pandas series) to its own row?
Here is my example data with two fields where the last one [outbreak] is a pandas series.
Start:
Goal (Excel mock-up):
Reproduction Code:
import pandas as pd
import json
d = {'report_id': [100, 101]...
1
vote
6
answers
62
views
How to filter list value in pandas
I'm new to this site and to Python and this question may be a bit basic.
I have a pandas Series that contains a list of elements in each row and I am trying to filter each list to only keep the ...
0
votes
0
answers
22
views
Time series: how to get a single number?
I need your help!
I have to replicate a table in which there are some variables ( gdp growth, labor share, etc)
I have a database that cointains for each country the times series ( 1960-2000) of the ...
2
votes
2
answers
34
views
Split data into columns in pandas
I have a df as
name category dummy
USA fx,ft,fe 1
INDIA fx 13
I need to convert this as
name category_fx categoty_ft category_fe dummy
USA True True True 1
...
3
votes
1
answer
50
views
pandas fillna sequentially step by step
I have dataframe like as below
Re_MC,Fi_MC,Fin_id,Res_id,
1,2,3,4
,7,6,11
11,,31,32
,,35,38
df1 = pd.read_clipboard(sep=',')
I would like to fillna based on two steps
a) First, compare only ...
-1
votes
2
answers
34
views
Create a Series of Dates between two Dates in a table - SQL
I have a table like this:
I want to list the rows per day between their Start Date and and End Date and Total Payment divided by number of days (I assume I would need a window function partition by ...
0
votes
1
answer
24
views
Aggregating pandas series into a DataFrame and visual representation
I have three pandas Series, called: Col_data, C_PV_data and C_elec_data. Each one has these values:
Col_data:
0 625814.205486
1 782267.756857
2 938721.308229
Name: 7, dtype: object
...
0
votes
0
answers
15
views
Reindexing with date range to add missing dates in time series data results in an empty data frame [duplicate]
I have a Pandas data frame that looks like this:
Date
Total Absences
17
2022-01-03
7
18
2022-01-04
16
19
2022-01-05
18
20
2022-01-07
18
and so on.....
As this data only has information from ...
0
votes
1
answer
21
views
Generating 3 columns from one with .apply on dataframe
I want to extract some data from each row, and make that new columns of existing or new dataframe, without repeatedly doing the same operation of re. match.
Here's how one entry of the dataframe looks:...
0
votes
0
answers
35
views
Can anyone tell me what the following [Pyright reportGeneralTypeIssues] error means, because when I run the program it runs normally
Can anyone tell me what the following [Pyright reportGeneralTypeIssues] error means, because when I run the program it runs normally...
import pandas as pd
obj = pd.Series([4, 7, -5, 3])
obj.index = ...
-1
votes
0
answers
30
views
Pandas Dataframe: How to iterate through the rows find the max based on constraints
I have a dataframe with three columns 'white', 'pink' and 'black' - I would like to find the 'maxvalue' and 'maxcluster' like below - The idea here is to capture the column name providing the maximum ...
0
votes
0
answers
9
views
Is there an R package including a function for the fractional integration test of Demetrescu, Kuzin and Hassler (2008)?
Question as stated in the title.
The fractional integration test is proposed by Demetrescu, M., Kuzin, V., & Hassler, U. (2008). Long memory testing in the time domain. Econometric Theory, 24(1), ...
0
votes
1
answer
25
views
Easiest/safest way to pass information cell by cell to a dataframe in pandas?
I have a very long algorithm I've been working on, and I would like to leave it running for days. I'd like to save the results and other variables to a dataframe for each loop and later pass them to a ...
0
votes
1
answer
33
views
Pandas vectorized way to tag first occurring value(m elements) in a series of m*n elements
I have a pandas series of m*n elements of the following form where m=5 and n=3 :
A: [1 1 1 1 1 0 1 1 0 0 0 0 0 1 1]
I need a result series as follows :
B: [1 0 0 0 0 0 1 0 0 0 0 0 0 1 0]
m and n can ...
0
votes
0
answers
29
views
Excel VBA graph based on Series not working properly
I'm using the following VBA code in Excel in order to produce 2 graphs with a data picked up from the sheet and slightly elaborated. As I'm not using ranges directly for the graphs and need to use ...
-2
votes
1
answer
27
views
Python pandas - series to dataframe
.
How do I print out only the country names that exist in the dataframe among series with country names as index?
0
votes
1
answer
12
views
How can I group elements in pandas series based on how many times they repeat?
I have this example_series:
0 False
1 False
2 False
3 False
4 False
5 False
6 False
7 False
8 False
9 False
10 False
11 False
12 False
13 True
14 ...
0
votes
0
answers
14
views
Area weighted average of wind speed gridded data
I have wind speed gridded data at a particular longitude and latitude. I want to calculate an area-weighted average of wind speed in R. I'm using package "ClimProjDiagsin" for area weighted ...
1
vote
1
answer
22
views
Creating a Series with labelled indexes
I don't get this. If I create a Series this way, with "tableur" being a DataFrame created from reading an excel file:
pd.Series(data=tableur["Info"].iloc[:,1])
I get what I expect,...
0
votes
2
answers
32
views
Variable not becoming a series of values. Why?
I created this script to detect Swing Highs and Lows and then to determine the High and Low values of these Swings. The code works for the last bar, but I would like these values to be a series I ...
0
votes
1
answer
46
views
How to store High or Low values (trading)
I would like to develop a code which add a Series to my DataFrame; the Series should store the lowest value of the Close until a new low is reached. When a new low is reached a new value should appear ...
0
votes
1
answer
35
views
What is the difference between `pandas.Series.ravel()`, `pandas.Series.to_numpy()`, `pandas.Series.values` and `pandas.Series.array`?
Basically the title sums it up. I have created a dummy pandas.Series object and looked up all these properties and methods. Documentation states that all of them except maybe pandas.array return numpy....
0
votes
0
answers
7
views
Using criterias and keeping original value when not meet. Value of a series ambigous?
I have a df with a list of text, some are correct others need to be updated. Have tried the following methods:
Method 1:
def criteria(row):
if row.Municipio.find ('Quetzaltenago')>=0:
...
1
vote
2
answers
27
views
Pandas .mean() method from .pct_change() returns nan value
I am currently trying to get the mean of a pandas series representing the percent change of another pandas series that is the percent change of the original series; however, when I try to get the mean ...
0
votes
1
answer
50
views
My program to find the solution of a series is giving me wrong answers
I was creating a program to find the solution to the series x - x^3/3! + x^5/5! - ... up to a certain term. The program is working but it is giving me wrong answers. Suppose if I take x = 5 and I ...
0
votes
0
answers
11
views
Merging three column in one new column Pandas [duplicate]
I have three columns to merge as in the attached image. Keeping the nan if it is present on all three columns or choosing the number if it is present in at least one column. How to do this, sorry for ...
1
vote
1
answer
35
views
Applying math formule to Pandas Series elements
Variables data, maxs and mins are Pandas Series with the same indexes.
I want to match the elements of the three variables by indexes.
How can I apply this function properly ?
def denormalize(data, ...
0
votes
0
answers
26
views
Iterating through a nested python dictionary TypeError: unhashable type: 'Series'
I have this form of a nested dictionary :
{
{"title_1" :{
{"title_1.1" : [float, float, Dataframe] },
{"title_1.2" : [float, float, Dataframe] },
{"title_1.3" : ...
5
votes
3
answers
64
views
How to refer to self in pandas subsetting
When I'm exploring data in an ad hoc way, I often have code like this:
X = (adj_all.o.diff(1) / adj_none.o.diff(1)).diff(1)
print(X[X > 0])
Is there a way to do this in a single line in an easy ...
1
vote
1
answer
40
views
Selecting first element of a series
I have an series object that contains multiple series (341 in this case):
I need to select only first element of each series. For example if I have series:
0 68 -0.22
86 2.54
1 73 -0.10
88 0.57
2 ...
0
votes
2
answers
49
views
How to store the minimum value of three different Series in a new Series?
here you are the code:
import yfinance as yf
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
ticker = "EURUSD=X"
df = yf.download(ticker, start='2021-1-1', interval='...
0
votes
1
answer
21
views
Convert series to pandas dataframe given the index as two columns with the same name and can t use reset_index
I have a series like this:
transaction_date transaction_date ticker
2012 9 DD 1
12 DD 1
2013 3 ...
0
votes
1
answer
32
views
TypeError: cannot convert the series to <class 'int'> python
In this function I'm trying to convert a series object to an int object. But when I try it I keep geting this error message TypeError: cannot convert the series to <class 'int'>. I have already ...
0
votes
2
answers
44
views
How do i sort the numeric values within a cell in Pandas series
I have a panda series/column where values are like -
Values
101;1001
130;125
113;99
1001;101
I need to sort the values within the cell with an expected outcome like below using python as the ...
0
votes
0
answers
19
views
Python Pandas: Subsetting gives back Series instead of integer [duplicate]
Say I have the following pd.DataFrame:
df = pd.DataFrame({'First Name': ['Kumar'],
'Last Name': ['Ram'],
'Country': ['India'],
'num_var': 1})
If I now ...
0
votes
1
answer
33
views
Sorting DataFrame and getting a value of column from it
I have the following dataframe:
newItem = pd.DataFrame({'c1': range(10), 'c2': (1,90,100,50,30,10,50,30,90,1000)})
Which looks like this:
I want to sort the columns by descending order, and extract ...
1
vote
1
answer
32
views
make a mean of several year dataframes, hour by hour
I have several dataframes of some value taken very hour, on several year, like this :
df1
Out[6]:
time P G(i) H_sun T2m WS10m Int
0 2005-01-01 00:10:00 0.0 0.0 ...
0
votes
1
answer
17
views
How to update a dataframe cells based on matching condition from another data frame. There are multiple matching rows and data to be updated is list
This is the dataframe which needs to be updated.
ID Doctor_Name ... Doctor_Office_Zipcode website
0 1 Wendy Mayer ... 10019 []
1 2 Michael S. Tseng ... ...
1
vote
2
answers
20
views
pandas.Series.to_csv or pandas.Series.to_excel - How to export two serie into on csv or xlsx file?
I have those series :
d = {'a': 1, 'b': 2, 'c': 3}
ser = pd.Series(data=d, index=['a', 'b', 'c']).rename('ser')
d2 = {'adf': 3, 'dfg': 6}
ser2 = pd.Series(data=d2, index=['adf', 'dfg']).rename('ser2')...
1
vote
1
answer
32
views
Handling features with multiple values per instance in Python for Machine Learning model
I am trying to handle my data set which contain some features that has some multiple values per instances as shown on the image
https://i.stack.imgur.com/D78el.png
I am trying to separate each value ...
0
votes
2
answers
28
views
Can't Change the First Value in a Series Using Index as a Method in Python
The following code is giving me some unexpected output. In summary, I am defining a Dictionary (dict2) and then creating a series out of it. Then, I am re-assigning a new value to the Math course and ...
1
vote
2
answers
58
views
Finding similarity score between two columns using pandas
I have a dataframe like as shown below
ID,Region,Supplier,year,output
1,Test,Test1,2021,1
2,dummy,tUMMY,2022,1
3,dasho,MASHO,2022,1
4,dahp,ZYZE,2021,0
5,delphi,POQE,2021,1
6,kilby,Daasan,2021,1
7,...
0
votes
1
answer
40
views
Curve Fitting Two Series Python
I am trying to curve fit a sinusoidal shaped data set, but I a getting an error saying 'Only size-1 arrays can be converted to Python scalars'. How do I correctly pass my two series for X and Y values ...
-1
votes
0
answers
28
views
Best practice for passing Pandas DataFrame, Series to functions
Is there conventional way to pass Series, DataFrames to function as argumenst?
For example I want to pass 2 columns from df1 and column from df2 to function foo:
df1 = pd.DataFrame(np.arange(9)....
0
votes
0
answers
20
views
Can I use neural networks to forecast the next 5000 values?
Suppose I trained a neural network (RNN, LSTM etc.) which takes 60 values as input to forecast the next (61st) value.
Now, I have a train set of 10,000 observations and test set of 5,000.
This is ...
-1
votes
2
answers
41
views
How extract variables from series
I have variable of type pandas.core.series.Series that consist several variables and their values as below example and I want to extract each variable to new series and its value.
How i can extract ...
-1
votes
0
answers
8
views
Is there a function that calculate infinite series A + A^2 + A^3 + and so on, where A is a Weighted Adjacency Matrix? (Useful for Equity Method Acct.)
Given a Weighted Adjacency Matrix A, whose I-J-element represents percentage share of company J held by company I DIRECTLY,
we know that I-J-element of matrix exponent A^2 is percentage share of ...
1
vote
3
answers
25
views
Assigning a Series to a pandas Dataframe depending on multiple different column entries
I have both a series as well as a DataFrame:
Series:
1 128
2 112
3 110
Where the Series index indicates a Month
DataFrame
month c1 c2
0 1 a 0
1 2 a ...