About Lesson
Join the conversation
![](https://codanics.com/wp-content/uploads/2023/10/IMG-20210112-WA0042-removebg-preview.jpg)
Here is my assignment link: https://colab.research.google.com/drive/1JUTEkTyliHUTXn8NvuuO9gqcPDuSOZ5F
Reply
![](https://codanics.com/wp-content/uploads/2023/10/IMG-20210112-WA0042-removebg-preview.jpg)
Sir I Done with the code => def convert_to_mb(size):
if size.endswith('k'):
return str(round(float(size[:-1]) / 1024)) + 'M'
else:
return size
df['Size'] = df['Size'].apply(convert_to_mb)
df.head(10)it work 100%
Reply
![](https://codanics.com/wp-content/uploads/2023/10/IMG-20210112-WA0042-removebg-preview.jpg)
I have read both blogs, but "Missing values ka rola" was very informative and attention-grabbing and warned me not to ignore missing values in any case.
Reply
![](https://codanics.com/wp-content/uploads/2023/10/IMG_1661.jpg)
# Assuming you have a DataFrame df and a column 'size_MB' containing sizes in MB
df['size_KB'] = df['size_MB'] * 1024
To convert Mbs to kbs in pyhton using pandas
Reply
import pandas as pd df = ... # your dataframe df['Size'] = df['Size'].str.lower() def convert_to_mb(size): if size[-1] == 'k': return f"{float(size[:-1]) * 1024/1024} Mb" else: return size df['Size'] = df['Size'].apply(convert_to_mb)
Reply
import pandas as pddf = ... # your dataframedf['Size'] = df['Size'].str.lower()def convert_to_mb(size):
if size[-1] == 'k':
return f"{float(size[:-1]) * 1024/1024} Mb"
else:
return size
df['Size'] = df['Size'].apply(convert_to_mb)
Reply
https://colab.research.google.com/drive/1AJ6tHeg7jCyJtt0TT6qa-ZZZQDgsVbeA?usp=sharing
Reply
Removing $ sign from Price columndf['Price'] = pd.to_numeric(df['Price'].str.replace('[$,]', '', regex=True), errors='coerce').fillna(0)non numeric value are filled with 0
Reply
df['Installs'] = df['Installs'].replace('[+,]', '', regex=True).astype(int)making binsbins = [0, 1000, 10000, 100000, 1000000, 10000000, 100000000, float('inf')]
labels = ['0-1k', '1k-10k', '10k-100k', '100k-1M', '1M-10M', '10M-100M', '100M+']NEW Column with New Values
df['Install Group'] = pd.cut(df['Installs'], bins=bins, labels=labels, right=False)
Reply
df['Size'] = df['Size'].replace('Varies with device', '')
Reply