Target and features variables shows empty dataframe i.e. Empty DataFrame Columns: [Year] Index: []

44 views Asked by At

Here is the co2 emission by country: Part1

Part2

I was trying to fit a model and predicted values was along x axis, then I tried to normalizing and then trying to fit. Now it shows empty dataframe.

Here is my code:

df['Value_co2_emissions_kt_by_country'].fillna((df['Value_co2_emissions_kt_by_country'].mean()), inplace=True)
df['Value_co2_emissions_kt_by_country'].mean()
# The Output:
159866.46268574602

df['Value_co2_emissions_kt_by_country'] = df['Value_co2_emissions_kt_by_country'].apply(str)
# normalizing
df=(df-df.mean(numeric_only=True))/df.std(numeric_only=True)

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler

x=pd.DataFrame(df['Year'][df['Entity']=='China'])
y=pd.DataFrame(df['Value_co2_emissions_kt_by_country'][df['Entity']=="China"])

print(x)
print(y)

The Output:

Empty DataFrame
Columns: [Year]
Index: []
Empty DataFrame
Columns: [Value_co2_emissions_kt_by_country]
Index: []

First I tried this

X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.33, random_state=42)

ValueError: With n_samples=0, test_size=0.33 and train_size=None, the resulting train set will be empty. Adjust any of the aforementioned parameters.

Then I tried to print x and y.

0

There are 0 answers