How to Read a Text File Seaborn

Photo by Markus Spiske on Unsplash

What you need before starting

Python

Seaborn

          pip install seaborn        

Pandas

          pip install pandas        

Jupyter notebook

          pip install jupyter        

Get to piece of work

          import os
import pandas equally pd
df = pd.read_csv('flights_tickets_serp2018-12-sixteen.csv')
          df.info()        

          df.describe()        

          df.head()        

          df.columns        

1. Remove useless characters

          df['title']        

Kickoff ten values in the "title" column
          spec_chars = ["!",'"',"#","%","&","'","(",")",
"*","+",",","-",".","/",":",";","<",
"=",">","?","@","[","\\","]","^","_",
"`","{","|","}","~","–"]
for char in spec_chars:
df['title'] = df['title'].str.replace(char, ' ')

String instance before removing the special grapheme

String instance later on removing the special character which creates an actress space
          df['title'] = df['title'].str.split().str.bring together(" ")        

2. Extract relevant content from a Series

          df['dollar_prices'] = df['title'].str.excerpt('(\$\.d*\.?\d*)')        
          df['dollar_prices'].unique()        

3. Check NaN values

          sns.heatmap(df.isnull(), cmap='viridis')        

          df = df.dropna(subset=['dollar_prices'])        

4. Change the type of your Series

          df['dollar_prices']            =            df['dollar_prices'].str.supersede('$', '')        
          df.dtypes        

          df['dollar_prices'] = pd.to_numeric(df['dollar_prices'], errors='coerce')        

Conclusion

yimhatemselithe1943.blogspot.com

Source: https://towardsdatascience.com/simplify-your-dataset-cleaning-with-pandas-75951b23568e

0 Response to "How to Read a Text File Seaborn"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel