C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD

# How to find value of this series using python?

By : Andreea Florescu
Date : November 19 2020, 12:41 AM
I think the issue was by ths following , This is the Taylor's series development of exp(-x). Recognizing this gives you a good opportunity to check your result against math.exp(-x).
Simple syntax improvements
code :
``````import math
a=input("Enter the no")
x=input("Enter value of x")
s=1
p=1
for i in range(1,a):
p=p*i
if(i%2!=0):
s=s-math.pow(x,i)/p
else:
s=s+math.pow(x,i)/p
print s
print math.exp(-x)
``````
``````import math
a=input("Enter the no")
x=input("Enter value of x")
s=1
p=1
for i in range(1,a):
p=p*i
s=s+math.pow(-x,i)/p
print s
print math.exp(-x)
``````

Share :

## Python: How to find properties of items in a series

By : Hiep Nghia Nguyen
Date : March 29 2020, 07:55 AM
like below fixes the issue If you are just looking for a well formated string (your example suggests it) you can use a label argument to the cut function.
code :
``````## create labels from breakpoints
breaks=[0,20,25,30,pd.np.inf]
diff=np.diff(breaks).tolist()

## make tuples of *breaks* and length of intervals
joint = list(zip(breaks,diff))

## format label
s1 = "{left:,.0f} to {right:,.0f}"
labels = [s1.format(left=yr[0], right=yr[0]+yr[1]-1) for yr in joint]
labels

['0 to 19', '20 to 24', '25 to 29', '30 to inf']
``````
``````df['agebin'] = pd.cut(df['agepreg'],breaks, labels=labels, right=False)
``````
``````df.groupby('agebin')['agebin'].size()
``````

## Python Pandas is it possible to find the max value in a generated series without having to store the series into memory?

Date : March 29 2020, 07:55 AM
this one helps. we can try to cheat, but we need to know the exact formula/algorithm.
In your example it can be done without storing the column:
code :
``````maximum = (df.a/df.index).max()
``````
``````maximum = df.assign(two=df.a/df.index)['two'].max()
``````
``````In [19]: df
Out[19]:
a  b  c
0   0  9  3
1   7  6  5
2   4  5  8
3   0  4  3
4   7  4  5
5   0  9  9
6   7  5  2
7   4  4  4
8   1  3  3
9   3  1  3
10  6  6  1
11  8  4  0
12  6  2  9
13  4  1  0
14  8  5  9

In [20]: df.assign(two=df.a/df.index)['two'].max()
Out[20]: 7.0

In [21]: (df.a/df.index).max()
Out[21]: 7.0
``````

## How do you find a series of characters in python?

By : TonyChen
Date : March 29 2020, 07:55 AM
wish help you to fix your issue To be more specific, given a string as such: XOOOO.XO. , This should do the trick:
code :
``````import re

def findPattern(s):
m = re.findall(r'(X)+(O)+(.)', s)
return len(m)
``````

## Matching two pandas series: How to find a string element from one series in another series and then create a new column

By : atruhoo
Date : March 29 2020, 07:55 AM
it helps some times Your loop was on the right track. The most readable and direct way I can think of to do this:
code :
``````def str_ops(x):
for y in real_model_names:
if y in x:
return y
return x

cars_em_df['commercial_name_cleaned'] = cars_em_df['commercial_name'].apply(str_ops)

# Result
cars_em_df
manufacturer_name_mapped                   commercial_name fuel_type_mapped  file_year  emissions    commercial_name_cleaned
0                     FIAT              124 gt multiair auto           Petrol       2018        153       124 gt multiair auto
1                     FIAT         500l wagon pop star t-jet           Petrol       2018        158  500l wagon pop star t-jet
2                     FIAT                doblo combi 1.4 95           Petrol       2018        165         doblo combi 1.4 95
3                     FIAT  panda  0.9t sge 85 natural power    NG-Biomethane       2018         86                      panda
4                     FIAT                 punto 1.4  77 lpg              LPG       2018        114                      punto
``````

## Python: How to find the indices of the first and last character in a consecutive series

By : Taoer
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Suppose I have string = "aaabaa" , Index of first a: