Pandas - ModuleNotFoundError - No Module Named Pandas and Functions Explained














































Pandas - ModuleNotFoundError - No Module Named Pandas and Functions Explained



Hello, Rishabh here:


This time I bring to you, some frequently used commands and functions in Panda and
handling of error named ModuleNotFoundError regarding panda.



Pandas- ModuleNotFoundError - No
Module Name Pandas Error Handled and Functions Explained


What's Pandas for?

Pandas has so many uses that it might make sense to list the things it can't do instead of what it can do. This tool is essentially your data is home. Through pandas, you get acquainted with your data by cleaning, transforming, and analyzing it.

For example, say you want to explore a dataset stored in a CSV on your computer. Pandas will extract the data from that CSV into a DataFrame a table, basically,  then let you do things like:

 1.      1. Calculate statistics and answer questions about the data, like      

               * What's the average, median, max, or min of each column?     

               * Does column A correlate with column B?     

               * What does the distribution of data in column C look like? 

 2.         2.  Clean the data by doing things like removing missing values and filtering rows or columns by some      criteria

 3.    3. Visualize the data with help from Matplotlib. Plot bars, lines, histograms, bubbles, and more.  

  4.    4. Store the cleaned, transformed data back into a CSV, other file or database


In this cheat sheet, we'll use the following shorthand:

  df |Any pandas DataFrame object 
  s | Any pandas Series object

To make use of the commands listed below, you'll need to first import the relevant libraries like so:

import pandas as pd
import numpy as np

 The Error is getting because you have not installed the Library.

To make sure that you're using the same pip as your pythonexecute the pip with whole path from python directory i.e.

C:Program FilesAnaconda3libsite-packages (python 3.6)pip install pandas

This will install the pandas in the same directory. Whichever Python you wand to use and install the pandas.If you want to use a specific version of Python in Windows cmd, just add the path of that Python in System Variables.

1. Install Pandas in Window :

Run the given statement in Command prompt.

pip install pandas

2. Install Pandas in Linux: 

 Run the given Statement in the Terminal.

sudo pip3 install pandas

3. For Anaconda.

Run the  given statement in Conda prompt.

conda install pandas



Pre-Defined Functions and Algorithms: 

Importing Data

Use these commands to import data from a variety of different sources and formats.  

pd          1.  pd.read_csv(filename) |From a CSV file

2.   pd.read_table(filename) | From a delimited text file (like TSV)

3.   pd.read_excel(filename) | From an Excel file

4.   pd.read_sql(query, connection_object) |Read from a SQL table/database

5.   pd.read_json(json_string) |Read from a JSON formatted string, URL or file.

6.   pd.read_html(url) | Parses an html URL, string or file and extracts tables to a list of dataframes

7.  pd.read_clipboard() | Takes the contents of your clipboard and passes it to read_table() 

         8.  pd.DataFrame(dict) |From a dict, keys for columns names, values for data as lists

Exporting Data

Use these commands to export a DataFrame to CSV, .xlsx, SQL, or JSON.   

df1         1.  df. to_csv(filename) |Write to a CSV file

2.   df.to_excel(filename) | Write to an Excel file

3.   df.to_sql(table_name, connection_object) |Write to a SQL table. 

         4.  df.to_json(filename) |Write to a file in JSON format 

Create Test Objects

These commands can be useful for creating test segments.    

pd          1.  pd.DataFrame(np.random.rand(20,5)) |5 columns and 20 rows of random floats

2.  pd.Series(my_list) | Create a series from an iterable my_list    

3.  df. index = pd.date_range('1900/1/30', periods=df.shape[0]) |Add a date index 


Viewing/Inspecting Data

Use these commands to take a look at specific sections of your pandas DataFrame or Series. 

  1.         1.  df.head(n) |First n rows of the DataFrame

2.   df.tail(n) | Last n rows of the DataFrame

3.   df.shape | Number of rows and columns

4.   df.info() | Index, Datatype and Memory information

5.  df.describe() | Summary statistics for numerical columns

6.  s.value_counts(dropna=False) |View unique values and counts  

         7.  df.apply(pd.Series.value_counts) |Unique values and counts for all columns 

Selection

Use these commands to select a specific subset of your data.

1.   df[col] |Returns column with label col as Series

2.  df[[col1, col2]] | Returns columns as a new DataFrame

3.  s.iloc[0] | Selection by position

4.  s.loc['index_one'] | Selection by index

5.  df.iloc[0,:] | First row              

                  6. df.iloc[0,0] |First element of first column 


Data Cleaning

Use these commands to perform a variety of data cleaning tasks.    

                  1.   df.columns = ['a','b','c'] | Rename columns

2.  pd.isnull() | Checks for null Values, Returns Boolean Arrray

3.  pd.notnull() | Opposite of pd.isnull()

4.  df.dropna() | Drop all rows that contain null values

5.  df.dropna(axis=1) | Drop all columns that contain null values

6.  df.dropna(axis=1,thresh=n) |Drop all rows have have less than n non null values

7.  df.fillna(x) | Replace all null values with x

8.  s.fillna(s.mean()) | Replace all null values with the mean

9.  s.astype(float) | Convert the datatype of the series to float

10. s.replace(1,'one') | Replace all values equal to 1 with 'one'

11. s.replace([1,3],['one','three']) |Replace all 1 with 'one' and 3 with 'three'

12. df.rename(columns=lambda x: x + 1) |Mass renaming of columns

13. df.rename(columns={'old_name': 'new_ name'}) |Selective renaming

14. df.set_index('column_one') |Change the index         

              15. df.rename(index=lambda x: x + 1) | Mass renaming of index 

Filter, Sort, and Groupby

Use these commands to filter, sort, and group your data.    

d1.                     1.     df[df[col] > 0.5] |Rows where the column col is greater than 0.5

2.  df[(df[col] > 0.5) & (df[col] < 0.7)] |Rows where 0.7 > col > 0.5

3.  df.sort_values(col1) | Sort values by col1 in ascending order

4.  df.sort_values(col2,ascending=False) |Sort values by col2 in descending order

5.  df.sort_values([col1,col2],ascending=[True,False]) |Sort values by col1 in ascending order then col2 in descending order

6.  df.groupby(col) | Returns a groupby object for values from one column

7.  df.groupby([col1,col2]) | Returns groupby object for values from multiple columns

8.  df.groupby(col1)[col2] | Returns the mean of the values in col2, grouped by the values in col1

9.  df.pivot_table(index=col1,values=[col2,col3],aggfunc=mean) | Create a pivot table that groups by col1 and calculates the mean of col2 and col3

10. df.groupby(col1).agg(np.mean) | Find the average across all columns for every unique col1 group

11. df.apply(np.mean) | Apply the function np.mean() across each column

12. nf.apply(np.max,axis=1) |Apply the function np.max() across each row



Join/Combine

Use these commands to combine multiple dataframes into a single one.  

                  1.   df1.append(df2) |Add the rows in df1 to the end of df2 (columns should be identical)

2.  pd.concat([df1, df2],axis=1) |Add the columns in df1 to the end of df2 (rows should be identical)      

             3.  df1.join(df2,on=col1,how='inner') |SQL-style join the columns in df1 with the columns                        in df2 where the rows for col have identical values. 'how' can be one                  
                  of 'left', 'right', 'outer', 'inner'

Statistics

Use these commands to perform various statistical tests. (These can all be applied to a series as well.) 

                  1.   df.describe() |Summary statistics for numerical columns

2.  df.mean() | Returns the mean of all columns

3.  df.corr() | Returns the correlation between columns in a DataFrame

4.  df.count() | Returns the number of non-null values in each DataFrame column

5.  df.max() | Returns the highest value in each column

6.  df.min() | Returns the lowest value in each column

7.  df.median() | Returns the median of each column   

             8.  df.std() |Returns the standard deviation of each column



----------------------------------------------



End.

Please comment below any questions or article requests.

Like the articles and Follow me to get notified when I post another article.

Cheerio!



More Articles of Rishabh Karmakar:

Name Views Likes
Basic Date and Time in Python 161 1
Using Defaultdict in Python 51 1
Floor Division in Python 202 1
Python time sleep function 77 1
Immutable Objects in Python 75 1
Mutable Objects in Python 80 1
Python Escape Sequences 69 1
Escape Sequence in Python 0 0
Python Bytearray 63 1
Plotting Histogram in Python 136 1
Using Voluptuous in Python 170 1
TRAINING MACHINE LEARNING MODEL WITH TENSORFLOW CLOUD 257 1
Pandas - ModuleNotFoundError - No Module Named Pandas and Functions Explained 5312 5
OpenCV - ModuleNotFoundError - No Module Named cv2 and Algorithms Explained 341 5
OpenCV - ModuleNotFoundError - No Module Named 270 9
Simple Python Project Mario Shooter Game 386 4
Web crawling using Python and Scrapy 265 6
CNN vs ANN vs RNN 284 6
Deep Learning - Activation and Loss Function 248 6
CNN vs. RNN vs. ANN 42 10
Advanced Python Projects Predicting and Forecasting Stock Market Prices 562 6
Intermediate Python Projects Tensorflow Live Object Detection 326 7
Intermediate Python Projects Optical Character and Text Recognizer from Live Images 336 7
Advanced Python Projects Analysing Music Trends and Recommendations 468 7
Advanced Python Projects Python Chatbot using NLTK and Keras 745 7
Advanced Python Projects CIFAR-10 Image Classification using Deep Learning 553 9
Advanced Python Projects Image Caption Generator using CNN and LSTM 451 10
Advanced Python Project Breast Cancer Classification using SVR 373 10
Advanced Python Project Smiling Face Detector using CNN 444 10
Advanced Python Project Handwritten Digit Recognizer 505 11
Intermediate Python Project Speed Typing in Python 455 10
Advanced Python Project Next Alphabet or Word Prediction using LSTM 365 12
Intermediate Python Project Find most similar word using Word2Vec 288 10
Advanced Python Projects IMDB Movie Review Sentiment Analysis 260 10
Intermediate Python Project Detection of Real or Fake News 282 10
Advanced Python Project Credit Card Fraud Detection 263 10
Intermediate Python Project Snake Game Pygame 326 10
Simple Python Projects Make a multi-colored rainbow pattern in Python 400 10
Advanced Project Analysis with Sentiment Classification using Bidirectional Recurrent Neural Network 244 10
Advanced Project Forest Fire Prediction using SVR Random Forest and Deep NN 378 10
Advanced Project Sentiment and WordCloud Analysis of Online Reviews 336 12
Python - Synthetic Data Generator for Machine Learning and Artificial Intelligence 263 9
Advanced Project Deep Dream AI 269 10
Python - Symbolic regression classification generator 268 9
Generate Polynomial Functions and Random Function Generator - Python 284 10
Intermediate Project Sentiment and WordCloud Analysis of Women E-Commerce 286 10
Intermediate Project Iris Data Classification 225 10
Intermediate Project Titanic Classification using Decision Tree 248 10
Machine Learning - Decision Tree in Python 293 9
Python - All about lambda functions 250 9
Machine Learning - Polynomial Regression in Python 276 9
Machine Learning - Multiple Linear Regression in Python 259 11
Machine Learning - Simple Linear Regression in Python 244 9
Implement all 2D and 3D types plots in Python 235 9
Implement 1D, 2D and 3D CNN in Python 310 9
Simple Python Projects Multiplayer Tic-Tac-Toe 269 11
Problem - Validating Credit Card Numbers Hackerrank 273 9
Problem - Linear Algebra using Numpy Hackerrank 706 9
Problem - Basic Spell Checker Hackerrank 214 9
Implement Binary Tree in Python 277 9
Implement Graph in Python 262 9
Python for Data Science 212 9
Simple Python Projects Select Region of Interest - OpenCV 323 10
Simple Python Projects Code to mask white pixels in a coloured image - OpenCV 333 10
Simple Python Projects Code to mask white pixels in a gray scale image - OpenCV 294 10
Simple Python Projects Convert colour image to gray scale and apply cartoon effects - OpenCV 347 10
Advanced Project - Automatic Facial Recognition Based Attendance System 700 9
Simple Python Projects Live Talking Counting Clock - Pyttsx3, Tkinter 262 10
Python Simple and Fast Text to Speech 225 9
Simple Python Projects Simple Zodiac Sign Teller 232 10
Simple Python Projects Simple Fortune Teller Game 275 10
Simple Python Projects Simple Guessing Game 389 10
Implementing Multi-line Strings 201 9
Save and Load Machine Learning Models in Python with scikit-learn 394 9
Use of Ternary operator for conditional assignment. 350 9
Chaining comparison operators 215 9
Implement Circular Singly Linked List 240 9
Implementing Command Line Arguments 355 9
Solve Knapsack Problem Using Dynamic Programming 383 10

Comments