Skip to content

Commit 8f0e05f

Browse files
committed
Initial commit
0 parents  commit 8f0e05f

File tree

7,594 files changed

+1758647
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,594 files changed

+1758647
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/Exercise_Matplotlib.iml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

NAN/-ve_value_change.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pandas as pd
2+
3+
data = pd.read_csv('covid_data.csv')
4+
print(data)
5+
print(data.query('new_cases < 0'))
6+
7+
data[data.new_cases < 0] = 0
8+
print(data)
9+
10+
df = data.fillna(0) # fills nan value with 0 to whole file
11+
#print(df)
12+
df.to_csv('df.csv', index=None)
13+
df.to_csv('df_with_index.csv')
14+
# data['iso_code'] = data['iso_code'].fillna(0) # fills nan value with 0 in a particular column
15+
# print(data)
16+
# print(data.info())
17+
18+
# final_df = df[['iso_code', 'location', 'date', 'total_cases', 'new_cases', 'total_deaths', 'positive_rate']]
19+
# print(final_df)

NAN/covid_data.csv

+46,485
Large diffs are not rendered by default.

NAN/df.csv

+46,485
Large diffs are not rendered by default.

NAN/df_with_index.csv

+46,485
Large diffs are not rendered by default.

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Exercise_Matplotlib
2+
Some initial exercises on Matplotlib

barplot.py

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import matplotlib.pyplot as plt
2+
import seaborn as sns
3+
import pandas as pd
4+
5+
covid_df = pd.read_csv('covid_data.csv')
6+
covid_df['date'] = pd.to_datetime(covid_df.date)
7+
covid_df['month'] = pd.DatetimeIndex(covid_df.date).month
8+
covid_df['weekday'] = pd.DatetimeIndex(covid_df.date).week
9+
covid_df['day'] = pd.DatetimeIndex(covid_df.date).day
10+
covid_df['year'] = pd.DatetimeIndex(covid_df.date).year
11+
print(covid_df.info())
12+
13+
new_df = covid_df[
14+
['iso_code', 'date', 'total_cases', 'new_cases', 'total_deaths', 'positive_rate', 'female_smokers', 'male_smokers',
15+
'month', 'weekday', 'day', 'new_deaths', 'year']]
16+
print(new_df.info())
17+
final_df = new_df.query("iso_code==['IND', 'USA', 'NZL', 'BRA']")
18+
print(final_df.nunique())
19+
plt.figure(figsize=(12, 6))
20+
sns.set_style('darkgrid')
21+
plt.title('Covid Cases of India')
22+
plt.xlabel('Month', size=14)
23+
plt.ylabel('New Cases', size=14)
24+
# plt.bar('month', 'new_cases', data=final_df)
25+
26+
27+
# sns.barplot(x='month', y='new_deaths', data=final_df, hue='iso_code', ci=68, palette='Blues_d', dodge=True,
28+
# saturation=60)
29+
30+
31+
# 1.Catplot
32+
# sns.catplot(x='month', y='new_deaths', data=final_df, ci=68, palette='Blues_d', dodge=True,
33+
# saturation=60, col='iso_code', kind='bar')
34+
35+
36+
# 2.Countplot
37+
# sns.countplot(x='iso_code', data=final_df, palette='Set3')
38+
39+
40+
# 3.Pointplot
41+
# sns.pointplot(x='month', y='new_cases', data=final_df.query("year==2020"), hue='iso_code', palette='Set2',
42+
# linestyles=['-', '--', '-.'],dodge=False, join=True)
43+
44+
45+
sns.catplot(x='month', y='new_cases', data=final_df.query("year==2020"), dodge=True,
46+
col='iso_code', height=5, aspect=0.4, kind='point', hue='day')
47+
plt.show()

car_crash_csv.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import matplotlib.pyplot as plt
2+
import seaborn as sns
3+
import numpy as np
4+
5+
car_crash = sns.load_dataset('car_crashes')
6+
# print(car_crash)
7+
print(car_crash, car_crash.info(), car_crash.describe(), car_crash.nunique())
8+
plt.figure(figsize=(20, 15))
9+
sns.set_style('darkgrid')
10+
plt.title('Car Crash')
11+
# plt.plot('alcohol', 'o-b', data=car_crash)
12+
# plt.plot('speeding', 'x--r', data=car_crash)
13+
# sns.lineplot('alcohol', 'speeding', data=car_crash)
14+
# plt.legend(['Speeding', 'Alcohol'])
15+
# plt.xlabel('Value')
16+
# plt.ylabel('Instances')
17+
18+
19+
# sns.scatterplot('speeding', 'alcohol', data=car_crash, hue='not_distracted', s=100)
20+
# plt.hist('speeding', data=car_crash)
21+
# plt.hist('alcohol', data=car_crash)
22+
# plt.hist(['speeding', 'alcohol'], bottom='speeding', data=car_crash,stacked=True)
23+
# plt.legend(['Alcohol', 'Speeding'])
24+
# sns.barplot('total', 'alcohol', data=car_crash.loc[20:50+1])
25+
# plt.bar('total', 'alcohol', data=car_crash.loc[20:50+1])
26+
# plt.hist('not_distracted', data=car_crash)
27+
# plt.plot('total', 'alcohol', 's--b', data=car_crash)
28+
#sns.histplot(x='alcohol', kde=True, data=car_crash)
29+
#sns.histplot(data=car_crash, x='total', stat='probability', discrete=True)
30+
#sns.histplot(data=car_crash, x='speeding', log_scale=True, fill=False, element='step')
31+
#sns.histplot(car_crash, x='alcohol', y='speeding')
32+
sns.histplot(car_crash, x='alcohol', element='poly')
33+
#sns.histplot(data=car_crash, x='speeding')
34+
sns.set_color_codes('muted')
35+
sns.barplot(x="abbrev", y="total", data=car_crash,
36+
label="Total", color="b")
37+
38+
plt.show()

catplot_pointplot.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import matplotlib.pyplot as plt
2+
import seaborn as sns
3+
import pandas as pd
4+
5+
df = sns.load_dataset('tips')
6+
sns.catplot(x="sex", y="total_bill",
7+
hue="smoker", col="time",
8+
data=df, kind="point",
9+
dodge=True,
10+
height=4, aspect=1)
11+
plt.show()

0 commit comments

Comments
 (0)