<jupyter_start><jupyter_text><jupyter_code>import pandas as pd
from google.colab import files
uploaded = files.upload()
for fn in uploaded.keys():
  print("User uploaded file'{name}' with length {length} bytes".format(name = fn, length=len(uploaded[fn])))
uploaded
import io
movies = pd.read_csv(io.StringIO(uploaded["tmdb-movies.csv"].decode("utf-8")))
movies.head(3)
movies.columns
movies.tail()
movies.shape
movies.describe()
movies.nunique()
movies.isnull().sum()
movies.drop(["id", "imdb_id", "popularity", "homepage", "director", "tagline",
            "keywords", "overview", "release_date", "vote_count",	"vote_average", "budget_adj",	"revenue_adj"], axis = 1, inplace=True)
movies.head()
movies.rename(columns = {"original_title":"title"}, inplace=True)
movies.head()
movies.shape
movies.isnull().sum()
movies["genres"].value_counts()
movies["genres"].fillna(value = "Various", inplace=True)
movies["genres"].isnull().sum()
 movies["cast"].fillna(value = "Various", inplace=True)
 movies["production_companies"].fillna(value = "Various", inplace=True)
movies.isnull().sum()
movies.describe()
import numpy as np
movies["budget"].replace(0, np.nan, inplace=True)
 movies["budget"].value_counts(dropna=False)
movies.isnull().sum()
movies.columns
import seaborn as sns
corelation = movies.corr()
sns.heatmap(corelation, xticklabels=corelation.columns, yticklabels=corelation.columns, annot = True)
sns.pairplot(movies)<jupyter_output><empty_output><jupyter_text>Q.1     Which are the movies with third lowest and third highest budget?<jupyter_code># Movies With Third Lowest Budget
info = pd.DataFrame(movies['budget'].sort_values(ascending = True))
info['title'] = movies['title']
data = list(map(str,(info['title'])))[2]
data
# Movies With Third Highest Budget
info = pd.DataFrame(movies['budget'].sort_values(ascending = False))
info['title'] = movies['title']
data = list(map(str,(info['title'])))[2]
data<jupyter_output><empty_output><jupyter_text>Q.2   Which are the movies with most and least earned revenue?<jupyter_code># Most Earned Revenue
movies.nlargest(1, ["revenue"])
# Least Earned Revenue
movies.nsmallest(1, ["revenue"])<jupyter_output><empty_output><jupyter_text>Q.3   What is the average runtime of the movies in the year 2006?<jupyter_code>movies[movies.release_year==2006].runtime.mean()<jupyter_output><empty_output><jupyter_text>Q.4   Name any 3 production companies which have invested money in worse revenue movies?<jupyter_code>movies["profit"] = movies["revenue"] - movies["budget"]
movies["profit"]
movies.head()
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
info_1 = list(map(str,(movies["production_companies"])))
production_companies = pd.DataFrame(production_companies)
info_2 = list(production_companies.index.values)
info_2.append("NaN")
movies["profit"] = movies["profit"].replace(np.NaN, 0)
profit = np.array(movies["profit"])
companies_df = pd.DataFrame(index = data3 ,columns =np.arange(0,1,1))
companies_df = companies_df.fillna(value = 0.0)
z = 0
for i in info_1:
    split_companies = list(map(str,i.split('|')))
    companies_df.loc[split_companies] = companies_df.loc[split_companies] + profit[z]
    z+=1
companies_df = companies_df.rename(columns={0:"Profit"})
companies_df[:30].plot.barh(figsize=(20,10),fontsize=12,legend=True)
plt.title("Production Companies Vs Profit",fontsize=15)
plt.xlabel("Profit",fontsize=13)
sns.set_style("whitegrid")<jupyter_output><empty_output><jupyter_text>From the above graph it can be concluded that the production companies which have invested in worst revenue movies are: 1.   BBC Films2.   Orion Pictures3.   Castle Rock Entertainment<jupyter_code>movies.to_pickle("movies.pkl")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15399086267132492, 'fraction_numerical': 0.013437248051599033, 'mean_word_length': 7.778301886792453, 'pattern_counts': {'":': 1, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '458947', 'license': 'Apache-2.0', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1297, 'n_words': 257, 'path': 'MiniProject.ipynb', 'repo_name': 'Gauravds435/colabtools', 'size': '3721'}