- import pandas as pd
- #import random and use it as random.sample
- from random import sample
- #Let us create some data using sample from random module
- #Create two lists
- country_list = ["USA", "Russia","China","India"]
- #Using the name list, let us create three variables using sample() function
- top1 = sample(country_list,4)
- top2 = sample(country_list,4)
- top3 = sample(country_list,4)
- #Now, we can use these lists to create a dataframe with 3 columns
- df = pd.DataFrame({"Top1":top1,
- "Top2":top2,
- "Top3":top3,
- })
- print(df)
-
- Active Topics
-
-
- by Eli 1 day ago All in One: YouTube, TED, X, Facebook and Instagram Reels, Videos, Images and Text Posts View the latest post Replies 332 Views 40356
- by Eli 1 day ago Iran's President Ebrahim Raisi Aged 63 Dies in a Helicopter Crash View the latest post Replies 3 Views 63
- by Eli 1 day ago Re: What is in Your Mind? View the latest post Replies 717 Views 307099
- by Eli 3 days ago PySpark for Large Data Processing View the latest post Replies 2 Views 8170
- by Eli 3 days ago Online Bible View the latest post Replies 3 Views 23330
- by Eli 3 days ago Generating SSH Key and Adding it to the ssh-agent for Authentication on GitHub View the latest post Replies 1 Views 487
- by Eli 1 week ago Russia Invades Ukraine View the latest post Replies 663 Views 240910
- by Eli 2 weeks ago President Museveni's Speech During International Development Association (IDA) Summit View the latest post Replies 1 Views 509
- by Eli 2 weeks ago From Simple Linear Regression Analysis to Covariance & Correlation to Independent Determinant, and R-Squared View the latest post Replies 11 Views 25143
- by Eli 2 weeks ago Collection of Greatest Christian Hymns of all Times View the latest post Replies 34 Views 72513
-
Live Programming and Computing with Python, R, Sage, Octave, Maxima, Singular, Gap, GP, HTML & Macaulay2
- Eli
- Senior Expert Member
- Reactions: 183
- Posts: 5410
- Joined: 9 years ago
- Location: Tanzania
- Has thanked: 75 times
- Been thanked: 88 times
- Contact:
Testing Sample Module
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 183
- Posts: 5410
- Joined: 9 years ago
- Location: Tanzania
- Has thanked: 75 times
- Been thanked: 88 times
- Contact:
Here is a SnapPy, what is it ?
SnapPy is a program for studying the topology and geometry of 3-manifolds, with a focus on hyperbolic structures. It runs on Mac OS X, Linux, and Windows, and combines a link editor and 3D-graphics for Dirichlet domains and cusp neighborhoods with a powerful command-line interface based on the Python programming language.
SnapPy can be installed on Linux as follows:
Ubuntu/Debian/Mint: Tested on Ubuntu 20.04:
Users of Ubuntu 18.04 or older should do:
On TSSFL Stack, SnapPy is installed and can be used via SageMath. We can at once import the whole Stack of SnapPy modules and start testing it immediatelly:
To explore SnapPy Manifold class for example (unfortunately tinker is not installed on SageMath), open Ubuntu LInux Terminal and evoke Python/Ipython interpreter, import Manifold and execute the below simple code:
SnapPy is a program for studying the topology and geometry of 3-manifolds, with a focus on hyperbolic structures. It runs on Mac OS X, Linux, and Windows, and combines a link editor and 3D-graphics for Dirichlet domains and cusp neighborhoods with a powerful command-line interface based on the Python programming language.
SnapPy can be installed on Linux as follows:
Ubuntu/Debian/Mint: Tested on Ubuntu 20.04:
- sudo apt-get install python3-tk python3-pip
- # Note no "sudo" on the next one!
- python3 -m pip install --upgrade --user snappy
- sudo apt-get install python3-tk python3-pip
- # Note no "sudo" on the next two
- python3 -m pip install --upgrade --user pip wheel
- python3 -m pip install --upgrade --user snappy
On TSSFL Stack, SnapPy is installed and can be used via SageMath. We can at once import the whole Stack of SnapPy modules and start testing it immediatelly:
- from snappy import Manifold, Triangulation, Manifold, ManifoldHP, AbelianGroup, FundamentalGroup, HolonomyGroup, HolonomyGroupHP, DirichletDomain, DirichletDomainHP, CuspNeighborhood, CuspNeighborhoodHP, SymmetryGroup, AlternatingKnotExteriors, NonalternatingKnotExteriors, SnapPeaFatalError, InsufficientPrecisionError, pari, twister, OrientableCuspedCensus, NonorientableCuspedCensus, OrientableClosedCensus, NonorientableClosedCensus, LinkExteriors, CensusKnots, HTLinkExteriors, TetrahedralOrientableCuspedCensus, TetrahedralNonorientableCuspedCensus, OctahedralOrientableCuspedCensus, OctahedralNonorientableCuspedCensus, CubicalOrientableCuspedCensus, CubicalNonorientableCuspedCensus, DodecahedralOrientableCuspedCensus, DodecahedralNonorientableCuspedCensus, IcosahedralNonorientableClosedCensus, IcosahedralOrientableClosedCensus, CubicalNonorientableClosedCensus, CubicalOrientableClosedCensus, DodecahedralNonorientableClosedCensus, DodecahedralOrientableClosedCensus, Crossing, Strand, Link, Tangle, RationalTangle, ZeroTangle, InfinityTangle, IdentityBraid, random_link, DTcodec
- A = AbelianGroup(elementary_divisors=[5,15,0,0])
- print(A)
- print(A[0])
- M = Manifold('m004')
- print(M.symmetry_group())
- M = Manifold('K7_1')
- G = M.fundamental_group()
- g = G.generators_in_originals()
- print(g)
- #M.inside_view()
- from snappy import Manifold
- M = Manifold('m004')
- M.inside_view()
- %gui tk
- #Code 2
- from snappy import ManifoldHP
- M = ManifoldHP('14n12345') #Try M = ManifoldHP('15n4321')
- M.volume()
- M.plink()
- M.browse()
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 183
- Posts: 5410
- Joined: 9 years ago
- Location: Tanzania
- Has thanked: 75 times
- Been thanked: 88 times
- Contact:
- import pandas as pd
- import re
- # Sample data
- data = {'date_time': ['Random text 2023-09-03 00:20:00 more text', 'Some other text', '2023-09-03 00:20:00 additional text']}
- df = pd.DataFrame(data)
- # Extract the first datetime occurrence with the desired format
- pattern = r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'
- first_datetime = re.search(pattern, ' '.join(df['date_time']))
- if first_datetime:
- # Extract the time from the first datetime occurrence
- first_time = first_datetime.group().split()[1]
- print(first_time)
- else:
- print("Datetime not found in DataFrame.")
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 183
- Posts: 5410
- Joined: 9 years ago
- Location: Tanzania
- Has thanked: 75 times
- Been thanked: 88 times
- Contact:
Python Polars is an alternative to Pandas, written with performance in mind. Test it:
- import polars as pl
- from datetime import datetime
- df = pl.DataFrame(
- {
- "integer": [1, 2, 3, 4, 5],
- "date": [
- datetime(2023, 1, 1),
- datetime(2023, 1, 2),
- datetime(2023, 1, 3),
- datetime(2023, 1, 4),
- datetime(2023, 1, 5),
- ],
- "float": [4.0, 5.0, 6.0, 7.0, 8.0],
- }
- )
- print(df)
- print(df.sample(2))
- print(df.describe())
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 183
- Posts: 5410
- Joined: 9 years ago
- Location: Tanzania
- Has thanked: 75 times
- Been thanked: 88 times
- Contact:
Test Vega Altair
- # import altair with an abbreviated alias
- import altair as alt
- # load a sample dataset as a pandas DataFrame
- from vega_datasets import data
- cars = data.cars()
- # make the chart
- chart = alt.Chart(cars).mark_point().encode(
- x='Horsepower',
- y='Miles_per_Gallon',
- color='Origin',
- ).interactive()
- chart.save('chart.html') # Save to file
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
-
- Similar Topics
- Replies
- Views
- Last post
-
- Information
-
Who is online
Users browsing this forum: No registered users and 0 guests