0
# Model SED

df2=pd.read_csv('fm10t5750g05k2odfnew.dat', skiprows =1 , delim_whitespace = True ) 
df2.rename({'VTURB=2':'wavelength','TITLE':'1','[-1.0]':'2', 'L/H=1.25' :'freq', 'NOVER' :'Hnu', 'NEW':'6', 'ODF':'7'}, axis =1 , inplace = True )
df2.drop ([ '1'] , axis =1 , inplace = True )
print (df2.columns)

df2.drop ( df2.tail (1).index, inplace = True )
df2.drop ( df2.head (30).index , inplace = True )

wave = np.array(df2['wavelength']) # nm 
flux_lamb_new= np.array(df2['Hnu']) 
modfreq = np.array(df2['freq']) 
wave_SI= np.array(wave) 
modfluxSI = modfreq*flux_lamb_new*4*np.pi

TypeError                                 Traceback (most recent call last)
Input In [279], in <cell line: 15>()
 13 modfreq = np.array(df2['freq']) 
 14 wave_SI= np.array(wave) 
---> 15 modfluxSI = modfreq*flux_lamb_new*4*np.pi

TypeError: can't multiply sequence by non-int of type 'float'

Since i'm new to python i am not sure how to proceed. if someone could help solve this i'd be grateful. Thanks!

Aadish
  • 1
  • 1
  • Does this answer your question? [Why do I get TypeError: can't multiply sequence by non-int of type 'float'?](https://stackoverflow.com/questions/485789/why-do-i-get-typeerror-cant-multiply-sequence-by-non-int-of-type-float) – Plagon Jan 04 '23 at 20:50
  • 1
    it may be the case that the df2['freq'] and df2['Hnu'] are both `str` and not float/int objects https://www.freecodecamp.org/news/typeerror-cant-multiply-sequence-by-non-int-of-type-float-solved-python-error/#:~:text=Error%20in%20Python-,To%20solve%20the%20TypeError%3A%20can't%20multiply%20sequence%20by%20non,multiplying%20it%20with%20a%20float.&text=If%20you%20convert%20the%20string,there%20will%20be%20no%20error. – Andrew Ryan Jan 04 '23 at 20:50
  • `modfreq` is an array. Multiplying an array by a floating-point value makes no sense. Did you intend to multiply _each element_ in the array, instead of _the array itself_? – John Gordon Jan 04 '23 at 20:52
  • @JohnGordon Multiplying a NumPy array by a floating-point value is the same thing as multiplying each element in the array by that value. So long as the elements in the NumPy array are actually *numbers*, it should work. – jjramsey Jan 04 '23 at 20:54
  • 1
    Look at `df2.dtypes()`. If columns contain strings they will be object dtype, and produce this error under multiplicition. – hpaulj Jan 04 '23 at 21:25
  • 1
    New or not, you have to know what's in your dataframe, and the file that it was derived from. You have that information; we don't. We can only guess as to what might be the problem. – hpaulj Jan 05 '23 at 00:37

0 Answers0