Department = input("Is there a list you would like to view")
readfile = pd.read_csv('6.csv')
filevalues= readfile.loc[readfile['Customer'].str.contains(Department, na=False), 'June-18\nQty']
filevalues = filevalues.fillna(int(0))
int_series = filevalues.values.astype(int)
calculated_series = int_series.apply(lambda x: filevalues*1.3)
print(filevalues)
I am getting this error : AttributeError: 'numpy.ndarray' object has no attribute 'apply'
I have looked through this website and no solutions seems to work. I simply want to multiply the data by 1.3 in this series. Thank you
There's two issues here.
.values you actually access the underlying numpy array; you no longer have a pandas.Series. numpy arrays do not have an apply method.apply for a simple multiplication, which will be orders of magnitude slower than using a vectorized approach.See below:
import pandas as pd
import numpy as np
df = pd.DataFrame({'a': np.arange(1000, dtype=np.float64)})
print(type(df['a']))
# Gives pandas.core.series.Series
print(type(df['a'].values))
# Gives numpy.ndarray
# The vectorized approach
df['a'] = df['a'] * 1.3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With