Quantcast
Viewing all articles
Browse latest Browse all 14069

TypeError: Could not convert to numeric

This is my code:

file_path = 'TEST3.csv'  # Update the path to your CSV filecolumns = ['Year','T', 'TM', 'Tm', 'PP', 'Yields_Blé_dur']n_steps_in, n_steps_out = 3, 1test_set_years = 5df = load_data(file_path)# Preprocess the datadf_processed = preprocess_data_columns(df, columns)# Extract 'Year' for plotting purposesyears = df_processed['Year'].values

[this is my database] (https://i.stack.imgur.com/SZgMR.png)

GitHub Link: https://github.com/Moiz1500/LSTM-model

I got this Error:

TypeError                                 Traceback (most recent call last)Cell In[44], line 10      7 df = load_data(file_path)      9 # Preprocess the data---> 10 df_processed = preprocess_data_columns(df, columns)     11 # Extract 'Year' for plotting purposes     12 years = df_processed['Year'].valuesCell In[33], line 2      1 def preprocess_data_columns(df, columns):----> 2     df = df[columns].fillna(df.mean())  #Fill NaN values with the mean of the column      3     return dfFile c:\Users\hemic\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\core\frame.py:11335, in DataFrame.mean(self, axis, skipna, numeric_only, **kwargs)  11327 @doc(make_doc("mean", ndim=2))  11328 def mean(  11329     self,   (...)  11333     **kwargs,  11334 ):> 11335     result = super().mean(axis, skipna, numeric_only, **kwargs)  11336     if isinstance(result, Series):  11337         result = result.__finalize__(self, method="mean")...-> 1678     raise TypeError(f"Could not convert {x} to numeric")   1679 try:   1680     x = x.astype(np.complex128)Type Error: Could not convert ['1/1/20121/2/20121/3/201212/31/2023'] to numeric.Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...

How would I go about fixing this error?

I don't know how I can convert Colum of Year to Date


Viewing all articles
Browse latest Browse all 14069

Trending Articles