Untitled
unknown
plain_text
a year ago
8.3 kB
10
Indexable
Here's a Python script that extracts 30 astronomical terms starting with "D" and exports them to an Excel file:
```python
import pandas as pd
# Define a dictionary of astronomical terms starting with "D"
astronomical_terms = {
"Dark matter": {
"Vietnamese": "Vật chất tối",
"Explanation": "A type of matter hypothesized to account for a large part of the total mass in the universe."
},
"Dark energy": {
"Vietnamese": "Năng lượng tối",
"Explanation": "A hypothetical form of energy that permeates all of space and accelerates the expansion of the universe."
},
"Dwarf planet": {
"Vietnamese": "Hành tinh lùn",
"Explanation": "A small planet that does not clear its neighboring region of other objects."
},
"Dwarf star": {
"Vietnamese": "Sao lùn",
"Explanation": "A small star that is less luminous than main sequence stars."
},
"Dark nebula": {
"Vietnamese": "Mây tối",
"Explanation": "A cloud of gas and dust in space causing darkness not due to a hot gas cloud."
},
"Day": {
"Vietnamese": "Ngày",
"Explanation": "The time it takes for Earth to rotate once around its axis, approximately 24 hours."
},
"Delta-v": {
"Vietnamese": "Delta-v",
"Explanation": "The change in velocity of a spacecraft needed to perform a maneuver or reach orbit."
},
"Dark adaptation": {
"Vietnamese": "Điều chỉnh ánh sáng tối",
"Explanation": "The process by which the eye adjusts to low light levels, necessary for observing dark sky objects."
},
"Dwarf galaxy": {
"Vietnamese": "Thiên hà lùn",
"Explanation": "A galaxy of smaller size and fewer stars compared to mainstream galaxies."
},
"Dawn": {
"Vietnamese": "Bình minh",
"Explanation": "The time when the Sun begins to rise from the viewpoint of an observer."
},
"Deceleration parameter": {
"Vietnamese": "Tham số giảm tốc",
"Explanation": "A measure of the rate at which the expansion of the universe is slowing down."
},
"Diffuse nebula": {
"Vietnamese": "Mây sao mờ",
"Explanation": "A cloud of interstellar gas and dust, often the site of star formation."
},
"Dark side of the Moon": {
"Vietnamese": "Mặt trăng hắc ám",
"Explanation": "The hemisphere of the Moon that is not visible from Earth due to synchronous rotation."
},
"Double star": {
"Vietnamese": "Sao đôi",
"Explanation": "A pair of stars that appear close to each other in the sky."
},
"Doppler effect": {
"Vietnamese": "Hiệu ứng Doppler",
"Explanation": "An increase or decrease in the frequency of sound, light, or other waves as the source and observer move towards or away from each other."
},
"Dynamical time": {
"Vietnamese": "Thời gian động lực",
"Explanation": "A time scale used in celestial mechanics to predict the positions of celestial objects."
},
"Disk galaxy": {
"Vietnamese": "Thiên hà đĩa",
"Explanation": "A galaxy characterized by a flat, rotating disk of stars, gas, and dust."
},
"Dark adaptation": {
"Vietnamese": "Điều chỉnh ánh sáng tối",
"Explanation": "The process by which the eye adjusts to low light levels, necessary for observing dark sky objects."
},
"Declination": {
"Vietnamese": "Sao khấu",
"Explanation": "The angular distance of a celestial object north or south of the celestial equator."
},
"Density wave theory": {
"Vietnamese": "Lý thuyết sóng mật độ",
"Explanation": "A theory describing spiral arm structure in galaxies as waves of increased density."
},
"Deep space": {
"Vietnamese": "Không gian sâu",
"Explanation": "The vast, empty regions of space beyond the Earth's atmosphere."
},
"Differential rotation": {
"Vietnamese": "Xoay chuyển biệt phân",
"Explanation": "Rotation of a star or planet at different rates at different latitudes or depths."
},
"Diurnal motion": {
"Vietnamese": "Chuyển động ngày",
"Explanation": "The apparent daily motion of celestial objects across the sky due to the rotation of the Earth."
},
"Double cluster": {
"Vietnamese": "Cụm đôi",
"Explanation": "A pair of star clusters located close together in the sky."
},
"Dust lane": {
"Vietnamese": "Vệt bụi",
"Explanation": "A dark band of interstellar dust observed in many spiral galaxies."
},
"Dynamo theory": {
"Vietnamese": "Lý thuyết động cơ",
"Explanation": "A theory explaining the generation of magnetic fields in celestial bodies through fluid motion."
},
"Dark region": {
"Vietnamese": "Vùng tối",
"Explanation": "An area of the sky where there are fewer stars and nebulae, often indicating a region of dust or gas."
},
"Doppler shift": {
"Vietnamese": "Dịch chuyển Doppler",
"Explanation": "The change in frequency or wavelength of a wave in relation to an observer who is moving relative to the wave source."
},
"Dust disk": {
"Vietnamese": "Đĩa bụi",
"Explanation": "A flat, rotating disk of dust and debris around a star or a young planetary system."
},
"Dark matter halo": {
"Vietnamese": "Vòng tối",
"Explanation": "A hypothetical component of a galaxy or galaxy cluster that envelops the visible parts."
},
"Dark cloud": {
"Vietnamese": "Mây tối",
"Explanation": "An interstellar cloud that is dense enough to obscure the light from stars behind it."
},
"Differential rotation": {
"Vietnamese": "Sự xoay biệt phân",
"Explanation": "The rotation of a celestial body where different parts rotate at different rates."
},
"Degenerate matter": {
"Vietnamese": "Chất thoái hóa",
"Explanation": "A state of matter under extreme pressure where quantum degeneracy pressure supports the object against gravitational collapse."
},
"Direct motion": {
"Vietnamese": "Chuyển động trực tiếp",
"Explanation": "The normal eastward motion of celestial bodies across the sky due to the rotation of the Earth."
},
"Dipole anisotropy": {
"Vietnamese": "Độ lệch cực",
"Explanation": "An uneven distribution of radiation in the Cosmic Microwave Background (CMB) that appears as a dipole pattern."
}
}
# Convert dictionary to DataFrame
df = pd.DataFrame.from_dict(astronomical_terms, orient='index')
df.index.name = 'English Term' # Set index name for Excel
# Specify the Excel file name
excel_file = "astronomical_terms_starting_with_D.xlsx"
# Export DataFrame to Excel
df.to_excel(excel_file, engine='openpyxl')
print(f"Excel file '{excel_file}' has been created successfully with 30 astronomical terms starting with 'D'.")
```
### Explanation of the Code:
- **Dictionary of Terms**: Contains 30 astronomical terms starting with "D", each with its Vietnamese translation and explanation.
- **DataFrame Creation**: Converts the `astronomical_terms` dictionary into a Pandas DataFrame (`df`) using `pd.DataFrame.from_dict()`.
- **Index Naming**: Sets the index name of the DataFrame to `'English Term'`.
- **Export to Excel**: Uses `df.to_excel()` to export the DataFrame to an Excel file named `"astronomical_terms_starting_with_D.xlsx"` using the `openpyxl` engine.
- **Confirmation**: Prints a message confirming the successful creation of the Excel file.
### Running the Code:
1. Copy the code into a Python script file (e.g., `export_astronomical_terms.py`).
2. Run the script using Python (`python export_astronomical_terms.py`).
3. Check your working directory for the generated Excel file (`astronomical_terms_starting_with_D.xlsx`).
This script will create an Excel file containing 30 astronomical terms starting with "D", along with their Vietnamese translations and explanations. Adjust the `astronomical_terms` dictionary to include additional terms or modify existing ones as needed.Editor is loading...
Leave a Comment