0
I’m trying to perform a filter on my dataframe (df_movies_usa
) to eliminate all other types of currency not represented by "$". The coin is in the column df_movies_usa["budget"]
.
I’m using the following code:
import pandas as pd
df_movies = pd.read_csv("IMDb movies.csv", sep = ",")
df_movies["country"] = df_movies["country"].str.replace("UK, USA", "USA")
df_movies["country"] = df_movies["country"].str.replace("USA, Canada", "USA")
df_movies["country"] = df_movies["country"].str.replace("Canada, USA", "USA")
df_movies["country"] = df_movies["country"].str.replace("USA, Germany", "USA")
df_movies_usa = df_movies[df_movies['country'] == "USA"]
df_movies_usa = df_movies_usa[df_movies_usa["budget"].str.contains("$")]
But the dataframe still contains all lines with other currency types (e.g., RUR)
Can you post the code so we can do the proper tests and try to help you?
– Jakson Fischer
Modified code!
– danimille
There was no code change, just the one I added
BB Code
...– Jakson Fischer
I’m new here, when you say to post the code, you want me to attach in extension ipynb the notebook here?
– danimille
You have more pieces than you posted, right? We need as much information as possible so that we can simulate your mistake and try to help you, with that, without the code, with just the part that’s making a mistake, we can’t help you.
– Jakson Fischer
I edited the question containing all the code
– danimille
Can give a
var_dump(df_movies_usa[df_movies_usa["budget"])
and post the result?– Jakson Fischer
Take a look at the documentation, I think this can help you and a lot: Documentation
– Jakson Fischer
Keyerror: "None of [Index([' 45000', ' 5700', ' 23500', ' 40000', ' 25000', ' 20000', ' 10000', n ' 50000', ' 17022', ' 50000', n ... n ' 5000000', ' 1500000', ' 130000', ' 95000', ' 1000', ' 100000', n ' 1500000', ' 3000000', ' 7000', ' 500000'], n dtype='Object', length=11132)] are in the [Columns]"
– danimille