Learn Python in Malayalam|Chapter 12|File handling in Python | Read & write a file






This is the 12th video on Learn python in Malayalam. This video clearly explains below topics,
use the below time link to skip to the specific topics

Topics covered in this video
Chapter 11 Assignment discussion -  00:48
File handling in python - 03:48
Generate file data - 04:38  
Save the data in a variable - 05:41
write data to a csv file - 06:18
read from the csv file - 08:46
plotting the data from the scv file - 09:52
standard deviation & mean of data - 11:09
location of the saved file - 11:57


Program used 

#importing libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Get x values of the wave
t = np.linspace(0,1,100)
# calculating the amplitude
y = np.sin(2*np.pi*t) # calculating sine wave
dat = [t,y]
# writing the value in to data.csv
df = pd.DataFrame(data=dat,index=["Time","Amplitude"]).T
# df
df.to_csv('data.csv')
#Reading the file data.csv
df1=pd.read_csv('data.csv',index_col=0)
# df1
#Plotting the function from read value
df1.plot(x="Time",y="Amplitude")
plt.show()
 
# Creating histogram 
df1.hist(column="Amplitude")
# Show plot 
plt.show() 
# Standard deviation of the value
print("Standard Deviation")
print(df1.std(0))
# Mean of the values
print("Mean")
print(df1.mean(0))

Assignment Solution
from numpy import *
from matplotlib.pyplot import *
# Get x values of the sine wave
t = arange(0, 10, 0.01);
# calculating the amplitude
y1 = cos(t)
y2 = cos(5*t)
y = y1*y2+y2
# plotting cos signals in subplot
rcParams["figure.figsize"] = (10,10) # changing the figure size 
fig, axs = subplots(3)
axs[0].plot(t,y1) 
axs[0].set_title("cos(t) signal ")
axs[1].plot(t,y2)
axs[1].set_title("cos(5*t) Signal")
axs[2].plot(t,y)  
axs[2].set_title("cos(t)*cos(5*t)+cos(5*t)")
show() # showing the figure

For more check out here : https://iammanuprasad.blogspot.com/

Learn Python in Malayalam Playlist: 
https://www.youtube.com/playlist?list=PLmKq-kgKY8uZya3cwcX6otT61NPHXbTK0

Chapter 1 -  https://youtu.be/WiyQ8wTsRO0
Introduction to programming
Introduction to Python
Introduction to Google Co-lab
How to setup Google Co-lab

Chapter 2 -  https://youtu.be/YFngtW42Mls
Python Identifiers
Lines and Indentation
Multi-Line Statements

Chapter 3 - https://youtu.be/gxalG8Aps0A
Quotation in python
Comments in python
Assigning values to variable

Chapter 4 - https://youtu.be/AaEL_f2RHIk
Data types
Numbers
Strings

Chapter 5 - https://youtu.be/irND35-6BZ0
Data types
Lists
Tuple
Dictionary

Chapter 6 - https://youtu.be/MRfg2QZBHvE
Decision making
if condition
if .. else condition
Nested if

Chapter 7 - https://youtu.be/VYXndepcTCM
Loops in Python
while loop
for loop
nested loop

Chapter 8 - https://youtu.be/d7Y2D9H4u7c
Functions in python
arguments in function
Multiple arguments in function
Arbitrary arguments in function
Return value in function

Chapter 9 - https://youtu.be/hFOTKyYCkdw 
Classes in python
Defining a class
Creating an object
Constructors in python

Chapter 10 - https://youtu.be/w-_x2vfpJk0
Matrix in python
Defining matrix in python
Matrix addition
Matrix multiplication
Transpose of a matrix
Inverse of matrix
Rank & eigen values of matrix

Chapter 11 - https://youtu.be/-7DB7OEenms
Plotting in Python
  Line Plot
  Stem Plot
  Bar Plot
  Scatter Plot
  Box Plot
  Histogram
  Multiple Plot, Subplot, plot within plot

If you like my video please subscribe my channel and share

Important links & key words

https://www.python.org/
Google COLAB

Music: https://www.bensound.com
Reff : https://www.tutorialspoint.com/python/python_variable_types.htm 
https://www.w3schools.com/

No comments:

Post a Comment

Signals & System Lect 15 | Stable & Unstable Systems | Solved examples

  ECT 204 SIGNALS AND SYSTEMS Topics covered  00:00 - Introduction to Stable & unstable Systems 01:08 - BIBO criteria 03:38 Problem No 1...