PYTHON Tutorial
Python is a versatile programming language widely used for data handling tasks. It offers a rich ecosystem of libraries, including pandas, numpy, csv, and json, that streamline data manipulation and analysis.
pd.read_csv('data.csv')
df.to_csv('output.csv')
pd.read_json('data.json')
df.to_json('output.json')
df[['column1', 'column2']]
df[df['column'] > 10]
df.groupby('column').agg({'value': 'mean'})
df['column'].mean()
plt.plot(df['x'], df['y'])
stats.linregress(df['x'], df['y'])
pd.TimeSeries()
import pandas as pd
# Import data from CSV
df = pd.read_csv('data.csv')
# Filter rows where 'age' is greater than 30
filtered_df = df[df['age'] > 30]
# Calculate the mean of 'salary'
mean_salary = df['salary'].mean()
# Create a scatter plot of 'age' vs 'salary'
plt.scatter(df['age'], df['salary'])
plt.xlabel('Age')
plt.ylabel('Salary')
plt.show()
Python's data handling capabilities are powerful and user-friendly. Understanding the key concepts and utilizing the available libraries empowers you to effectively manipulate, analyze, and visualize data for various applications.