Skip to content

Commit

Permalink
Practice task - changing histogram numbers to percentages
Browse files Browse the repository at this point in the history
  • Loading branch information
Lawrence Chen authored and Lawrence Chen committed Oct 23, 2023
1 parent b7b28f0 commit fe13790
Show file tree
Hide file tree
Showing 18 changed files with 1,804 additions and 941,754 deletions.
14 changes: 8 additions & 6 deletions analysis/log/make.log
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
--------------------------------------------------------------------------------
Makelog started: 2023-07-03 14:42:07
Working directory: /Users/jccp/Desktop/template/analysis
Makelog started: 2023-10-22 16:17:49
Working directory: /Users/lawrencechen/Desktop/gentzkow/analysis
--------------------------------------------------------------------------------
Input links successfully created!
External links successfully created!
Source logs successfully written!
WARNING! The following target files have been modified according to git status:
/Users/lawrencechen/Desktop/gentzkow/data/output/data_cleaned.csv
Version logs successfully written!
Executing command: `python "/Users/jccp/Desktop/template/analysis/code/analyze_data.py" `
/usr/local/Caskroom/miniconda/base/envs/template/lib/python3.11/site-packages/linearmodels/panel/model.py:1214: MissingValueWarning:
Executing command: `python "/Users/lawrencechen/Desktop/gentzkow/analysis/code/analyze_data.py" `
/opt/homebrew/Caskroom/miniconda/base/envs/template/lib/python3.11/site-packages/linearmodels/panel/model.py:1214: MissingValueWarning:
Inputs contain missing values. Dropping rows with missing observations.
super().__init__(dependent, exog, weights=weights, check_rank=check_rank)

Output logs successfully written!
--------------------------------------------------------------------------------
Makelog ended: 2023-07-03 14:42:44
Working directory: /Users/jccp/Desktop/template/analysis
Makelog ended: 2023-10-22 16:17:53
Working directory: /Users/lawrencechen/Desktop/gentzkow/analysis
--------------------------------------------------------------------------------
2 changes: 1 addition & 1 deletion analysis/log/output_stats.log
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
file name | last modified | file size
/Users/jccp/Desktop/template/analysis/output/regression.csv | 2023-07-03 21:42:44 | 58
/Users/lawrencechen/Desktop/gentzkow/analysis/output/regression.csv | 2023-10-22 23:17:54 | 58
4 changes: 2 additions & 2 deletions analysis/log/source_map.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
destination | source
input/lib | /Users/jccp/Desktop/template/lib
input/data_cleaned.csv | /Users/jccp/Desktop/template/data/output/data_cleaned.csv
input/lib | /Users/lawrencechen/Desktop/gentzkow/lib
input/data_cleaned.csv | /Users/lawrencechen/Desktop/gentzkow/data/output/data_cleaned.csv
1,421 changes: 723 additions & 698 deletions analysis/log/source_stats.log

Large diffs are not rendered by default.

310 changes: 149 additions & 161 deletions analysis/log/versions.log

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions analysis/output/regression.csv
Git LFS file not shown
14 changes: 13 additions & 1 deletion data/code/clean_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ def main():
df.to_csv('output/data_cleaned.csv', index = False)

def plot_data(df):
plt.hist(df['chips_sold'])
# Create figure in axes
fig, ax = plt.subplots()

# Plot histogram of chips_sold column
ax.hist(df['chips_sold'])

# Set y-axis ticks as percentages
ax.yaxis.set_major_formatter(plt.FuncFormatter(lambda y, _: f'{y / len(df) * 100:.0f}%'))

# Set y-axis label
ax.set_ylabel('Percentage')

# Save plot to PDF file
plt.savefig('output/chips_sold.pdf')

def clean_data(df):
Expand Down
20 changes: 10 additions & 10 deletions data/log/make.log
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
--------------------------------------------------------------------------------
Makelog started: 2023-07-03 14:41:30
Working directory: /Users/jccp/Desktop/template/data
Makelog started: 2023-10-22 16:42:26
Working directory: /Users/lawrencechen/Desktop/gentzkow/data
--------------------------------------------------------------------------------
Input links successfully created!
External links successfully created!
Source logs successfully written!
WARNING! The following target files have been modified according to git status:
/Users/lawrencechen/Desktop/gentzkow/raw/tv.csv
/Users/lawrencechen/Desktop/gentzkow/raw/chips.csv
Version logs successfully written!
Executing command: `python "/Users/jccp/Desktop/template/data/code/merge_data.py" `
Executing command: `python "/Users/jccp/Desktop/template/data/code/clean_data.py" `
/Users/jccp/Desktop/template/data/code/clean_data.py:17: SettingWithCopyWarning:
Executing command: `python "/Users/lawrencechen/Desktop/gentzkow/data/code/merge_data.py" `
Executing command: `python "/Users/lawrencechen/Desktop/gentzkow/data/code/clean_data.py" `
/Users/lawrencechen/Desktop/gentzkow/data/code/clean_data.py:29: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
df['chips_sold'][df['chips_sold'] == -999999] = np.NaN

Output logs successfully written!
WARNING! Certain files tracked by git exceed the config size limit (0.5 MB). See below for list of files.
/Users/jccp/Desktop/template/data/output/data_merged.csv
/Users/jccp/Desktop/template/data/output/data_cleaned.csv
--------------------------------------------------------------------------------
Makelog ended: 2023-07-03 14:42:06
Working directory: /Users/jccp/Desktop/template/data
Makelog ended: 2023-10-22 16:42:32
Working directory: /Users/lawrencechen/Desktop/gentzkow/data
--------------------------------------------------------------------------------
6 changes: 3 additions & 3 deletions data/log/output_stats.log
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
file name | last modified | file size
/Users/jccp/Desktop/template/data/output/data_cleaned.csv | 2023-07-03 21:42:07 | 10260923
/Users/jccp/Desktop/template/data/output/data_merged.csv | 2023-07-03 21:41:58 | 10290907
/Users/jccp/Desktop/template/data/output/chips_sold.pdf | 2023-07-03 21:42:06 | 6920
/Users/lawrencechen/Desktop/gentzkow/data/output/data_merged.csv | 2023-10-22 23:42:30 | 10294275
/Users/lawrencechen/Desktop/gentzkow/data/output/data_cleaned.csv | 2023-10-22 23:42:32 | 10265592
/Users/lawrencechen/Desktop/gentzkow/data/output/chips_sold.pdf | 2023-10-22 23:42:31 | 9940
6 changes: 3 additions & 3 deletions data/log/source_map.log
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
destination | source
input/lib | /Users/jccp/Desktop/template/lib
input/tv.csv | /Users/jccp/Desktop/template/raw/tv.csv
input/chips.csv | /Users/jccp/Desktop/template/raw/chips.csv
input/lib | /Users/lawrencechen/Desktop/gentzkow/lib
input/tv.csv | /Users/lawrencechen/Desktop/gentzkow/raw/tv.csv
input/chips.csv | /Users/lawrencechen/Desktop/gentzkow/raw/chips.csv
Loading

0 comments on commit fe13790

Please sign in to comment.